NSM Lab Arguments
NSM Lab Arguments
16
feps-
teach02 .1.3.6.1.2.1.6.13.1.1 .1.3.6.1.2.1.6.13.1.2 .1.3.6.1.2.1.6.13.1.3 .1.3.6.1.2.1.6.13.1.4 .1.3.6.1.2.1
.6.13.1.5
1) Listen in the 2nd code : 1) I need to show for all the 6 oids and change the window size
constantly and show the output before calculating the output and after caculating the output.
2) Understand how does UWMA is calculated.
------------------------------------------------------------------------------------------------------------------------
Window Size tcpInSegs tcpOutSegs ifInOctets ifOutOctets ipInDelivers ipOutRequests
feps-teach02
2 .1.3.6.1.2.1.2.2.1.10 .1.3.6.1.2.1.2.2.1.16 .1.3.6.1.2.1.2.2.1.10 .1.3.6.1.2.1.2.2.1.16 .1.3.6.1.2.1.4.9 .1.
3.6.1.2.1.4.10
========================================================================
=
package UWMA;
import com.adventnet.snmp.snmp2.*;
import java.util.*;
try {
session.open();
} catch (SnmpException e) {
System.err.println("Error opening SNMP session: " + e);
api.close();
System.exit(1);
}
printHeaders();
Thread.sleep(pollingPeriod * 1000);
while (true) {
long currentValue = fetchSnmpValue(session, oid);
values.add(currentValue);
{ Thread.sleep(pollingPeriod * 1000);}
}
}
}
private static void printRow(int windowSize, String oid, long rawValue, double
uwmaValue) {
System.out.printf("%-12d %-12.2f %-12d %-12d %-12.2f %-12.2f %-12d %-12.2f
%-12d %-12.2f %-12d%n",
windowSize, getUWMAValue(oid, uwmaValue), rawValue,
rawValue, getUWMAValue(oid, uwmaValue),
getUWMAValue(oid, uwmaValue), rawValue,
getUWMAValue(oid, uwmaValue), rawValue,
getUWMAValue(oid, uwmaValue), rawValue);
}
try {
SnmpPDU response = session.syncSend(pdu);
if (response == null) {
System.err.println("Received null response, assuming no data
available.");
return 0;
}
Iterator<Long> it = values.descendingIterator();
long current = it.next();
double sumDifferences = 0;
int count = 0;
package UWMA;
import com.adventnet.snmp.snmp2.*;
import java.util.*;
try {
session.open();
} catch (SnmpException e) {
System.err.println("Error opening SNMP session: " + e);
api.close();
System.exit(1);
}
printHeaders();
while (true) {
long inCurrentValue = fetchSnmpValue(session, oidIn);
long outCurrentValue = fetchSnmpValue(session, oidOut);
inValues.add(inCurrentValue);
outValues.add(outCurrentValue);
Thread.sleep(pollingPeriod * 1000);
}
}
try {
SnmpPDU response = session.syncSend(pdu);
if (response == null) {
System.err.println("Received null response, assuming no data
available.");
return 0;
}
Iterator<Long> it = values.descendingIterator();
long current = it.next();
double sumDifferences = 0;
int count = 0;
package UWMA;
import com.adventnet.snmp.snmp2.*;
import java.util.*;
try {
session.open();
} catch (SnmpException e) {
System.err.println("Error opening SNMP session: " + e);
api.close();
System.exit(1);
}
printHeaders();
while (true) {
long inCurrentValue = fetchSnmpValue(session, oidIn);
long outCurrentValue = fetchSnmpValue(session, oidOut);
inValues.add(inCurrentValue);
outValues.add(outCurrentValue);
Thread.sleep(pollingPeriod * 1000);
}
}
try {
SnmpPDU response = session.syncSend(pdu);
if (response == null) {
System.err.println("Received null response, assuming no data
available.");
return 0;
}
double sum = 0;
int count = 0;
long current = it.previous(); // Start with the most recent value