Ivan Mladenović
2010-04-07 08:20:11 UTC
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âŠ
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âŠ