[SNMP4J] SNMP Walk?

Frank Fock fock at agentpp.com
Tue Feb 10 22:30:24 CET 2009


Basically, you need to specify the received
OID in the next request.
Alternatively, you can use TreeUtils and
TableUtils from the org.snmp4j.util package.

Best regards,
Frank

Mathew Rowley wrote:
> 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.

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list