[SNMP4J] SNMP Walk?
Mathew Rowley
mathew_rowley at cable.comcast.com
Tue Feb 10 21:58:40 CET 2009
When trying to get a list of MAC addresses from a CMTS, it seems like I need
to send PDU.GETNEXT until the sub-tree has been exhausted. How would this
be done with the API? It would seem like this would work, but I just receive
the same MAC over and over again.
CODE:
// setting up target
Address targetAddress =
GenericAddress.parse("udp:10.252.74.164/161");
CommunityTarget target = new CommunityTarget();
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
target.setCommunity(new OctetString("Q845q8st"));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version1);
snmp.listen();
// creating PDU
PDU pdu = new PDU();
pdu.add(new VariableBinding(new
OID("1.3.6.1.2.1.10.127.1.3.3.1.2"))); // docsIfCmtsCmStatusMacAddress -
MAC ADDRESS OF THE CM CABEL INTERFACE
pdu.setType(PDU.GETNEXT);
ResponseEvent resp = snmp.send(pdu, target);
snmp.send(pdu, target);
System.out.println(resp.getRequest());
while(resp.getResponse().getErrorIndex() == 0 ){
System.out.println(resp.getResponse());
snmp.send(pdu, target);
resp = snmp.send(pdu, target);
}
snmp.close();
}
OUTPUT:
GETNEXT[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2 = Null]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
RESPONSE[requestID=250464773, errorStatus=Success(0), errorIndex=0,
VBS[1.3.6.1.2.1.10.127.1.3.3.1.2.491521 = 00:00:ca:d6:01:ee]]
Thanks for any help.
--
MAT
More information about the SNMP4J
mailing list