[SNMP4J] How to send synchronous SNMP GET response?

Ivan Mladenović piffta at gmail.com
Wed Apr 7 10:20:11 CEST 2010


Hi to all,

I’m trying to implement SNMP GET operation. I want to send a synchronous
SNMP get request, and to process response.

I try something like this:

Address targetAddress = GenericAddress.*parse*("udp:127.0.0.1/161");



CommunityTarget target = *new* CommunityTarget();

target.setCommunity(*new* OctetString("public"));

target.setAddress(targetAddress);

target.setRetries(1);

target.setTimeout(10000);

target.setVersion(SnmpConstants.*version2c*);



// creating PDU

PDU pdu = *new* PDU();

pdu.add(*new* VariableBinding(new OID(new int[] {1,3,6,7}));

pdu.setType(PDU.*GET*);

pdu.setErrorIndex(0);

pdu.setErrorStatus(PDU.*noError*);

pdu.setMaxRepetitions(1);



TransportMapping transport = *new* DefaultUdpTransportMapping();

Snmp snmp = *new* Snmp(transport);



transport.listen();



ResponseEvent response = snmp.send(pdu, target);


I got some response (not null), but for response.getResponse() I got null.

When I try this from MIB browser, I get response with information that I
want to get.

I suppose here is something wrong.

Could you please give me some example or tell me what I’m doing wrong?

Thans…



More information about the SNMP4J mailing list