[SNMP4J] snmp()
Anthony Alessi
anthony at vigo-alessi.com
Fri Nov 7 22:40:33 CET 2008
Hello all,
I am new to SNMP4J programming. I am trying to initialize Snmp
with the basic constructor. I can get it to work if I use the constructor
and specify the Transport Mapping. Searching though the Mailing List Archive
I came across a message from Frank:
Hi Afnan,
When using the Snmp() constructor you need to manually add the
MessageProcessingModels (MPV1,MPV2c, or MPv3) and
SecurityModels (USM) you want to use.
The current JavaDoc is wrong and will be fixed for the next release.
Best regards,
Frank
My Problem is that I can't see how to accomplish this in the JavaDocs.
Please help. I have included the relevant parts of my code below.
Address targetAddress = GenericAddress.parse("udp:"
+ addr + "/161");
TransportMapping transport = new
DefaultUdpTransportMapping();
snmp = new Snmp(); //This works when:
snmp = new Snmp(transport)
snmp.addTransportMapping(transport);
transport.listen();
// setting up target
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(com));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version1);
// creating PDU
PDU_Accumulator requestPDU = new PDU_Accumulator();
PDU responsePDU = new PDU();
requestPDU.setType(PDU.GET);
requestPDU.addNetworkUtilizationRequest(index);
ResponseEvent event = snmp.send(requestPDU, target,
transport);
Thanks,
Anthony Joseph Alessi
More information about the SNMP4J
mailing list