[SNMP4J] SNMP4J Starting up problems
Frank Fock
fock at agentpp.com
Thu Jul 31 22:31:40 CEST 2008
Hello,
You need to configure the USM indeed.
See http://www.snmp4j.org/doc/org/snmp4j/Snmp.html
for an example. The error code you get is described here:
http://www.snmp4j.org/doc/org/snmp4j/mp/SnmpConstants.html
Best regards,
Frank
Oosten, Harry van schrieb:
> Hello,
>
>
>
> As a requirement for an application I need to build in option to request
> some OID from switches and/or a APC.
>
> I have tried to create a testclass based on the examples given in the
> API.
>
>
>
> I think I don't get the whole idea to make things work. I want to know
> what I need to create this functionality:
>
>
>
> - SNMPv3
>
> - Polling Switches and/or APC
>
> - Acting on value from the response
>
>
>
> I've tried to create an UserTarget and ScopedPDU
>
>
>
> private ScopedPDU createScopedPdu() {
>
> ScopedPDU pdu = new ScopedPDU();
>
> pdu.add(new VariableBinding(new OID(".1.3.1.2.6.1.2.1.1.2")));
>
>
>
> pdu.setType(PDU.GETBULK);
>
> pdu.setMaxRepetitions(50);
>
> pdu.setNonRepeaters(1);
>
>
> pdu.setContextEngineID(OctetString.fromHexString("80:00:13:70:c0:a8:01:0
> d"));
>
> return pdu;
>
> }
>
>
>
> private UserTarget createUserTarget() {
>
> UserTarget target = new UserTarget();
>
> target.setAddress(new UdpAddress("127.0.0.1/161"));
>
> target.setRetries(1);
>
> target.setTimeout(500);
>
> target.setVersion(SnmpConstants.version3);
>
> target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
>
> target.setSecurityName(new OctetString("MD5DES"));
>
> return target;
>
> }
>
>
>
> With these to tried to send the message:
>
>
>
> private void sendMessage(ScopedPDU requestPDU, UserTarget target) throws
> IOException {
>
> Snmp snmp = null;
>
> try {
>
> snmp = new Snmp(new DefaultUdpTransportMapping());
>
> snmp.listen();
>
>
>
>
>
> } catch (IOException ex) {
>
>
> Logger.getLogger(MySnmpTest.class.getName()).log(Level.SEVERE, null,
> ex);
>
> }
>
> ResponseEvent response = snmp.send(requestPDU, target);
>
> if (response.getResponse() == null) {
>
> // request timed out
>
> } else {
>
> System.out.println("Received response from: " +
>
> response.getPeerAddress());
>
> // dump response PDU
>
> System.out.println(response.getResponse().toString());
>
> }
>
> }
>
>
>
> There are a few things I don't understand first off all get an
> stacktrace:
>
>
>
> Exception in thread "main" org.snmp4j.MessageException: Message
> processing model 3 returned error: -1402
>
> at
> org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:458)
>
> at org.snmp4j.Snmp.sendMessage(Snmp.java:951)
>
> at org.snmp4j.Snmp.send(Snmp.java:808)
>
> at org.snmp4j.Snmp.send(Snmp.java:760)
>
> at test.MySnmpTest.sendMessage(MySnmpTest.java:87)
>
> at test.MySnmpTest.go(MySnmpTest.java:48)
>
> at test.MySnmpTest.main(MySnmpTest.java:42)
>
>
>
> Second of all where do I need to configure my username and password for
> the connection?
>
>
>
> Thanks in advance. Any help would be welcome.
>
>
>
> Met vriendelijke groet / Kind Regards,
>
>
>
> ing. Harry van Oosten
>
>
>
> Software engineer
>
> _________________________________________
>
>
>
>
>
> This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
More information about the SNMP4J
mailing list