[SNMP4J] Discover SNMPv3 Devices

Frank Fock fock at agentpp.com
Thu Feb 17 01:22:40 CET 2011


Hi Daniel,

What your are going to try is simply impossible.
You cannot use multicast with SNMPv3, because
each agent has its unique engine ID and the manager
must use that ID it its requests.

Best regards,
Frank

On 15.02.2011 09:27, Daniel Boschofsky wrote:
> Hi there,
>
> I am pretty new to mailinglists and SNMP4J.
>
> I am trying to write a little application which lists all SNMPv3 devices in
> the network and show some information. Reading information from a single
> known host is no problem at all, but I cant discover all devices. I tried it
> via a simple broadcast but it ends with a NullPointerException. If I use the
> snmpgetnext command from bash, I get an "Unknown Engine ID (Permission
> denied)". Probably it is the same problem with SNMP4J. So how can I send a
> simple SNMPv3 request to all nodes without incrementing the IP and sending
> the request to each existing address in the network.
>
> Sincerely,
> Daniel B.
>
> ---
> My code so far for testing:
>
> public static void main(String[] args) {
> Snmp snmp;
> Address targetAddress = GenericAddress.parse("udp:10.13.255.255/161");
> TransportMapping transport = new DefaultUdpTransportMapping();
> snmp = new Snmp(transport);
> USM usm = new USM(SecurityProtocols.getInstance(),
> new OctetString(MPv3.createLocalEngineID()),
> 0);
>
> SecurityModels.getInstance().addSecurityModel(usm);
> transport.listen();
>
> snmp.getUSM().addUser(new OctetString("HelloSnmp"),
> new UsmUser(new OctetString("HelloSnmp"),
> AuthMD5.ID,
> new OctetString("Hello123"),
> PrivDES.ID,
> new OctetString("Hello123")));
>
> UserTarget target = new UserTarget();
> target.setAddress(targetAddress);
> target.setRetries(1);
> target.setTimeout(5000);
> target.setVersion(SnmpConstants.version3);
> target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
> target.setSecurityName(new OctetString("HelloSnmp"));
>
> OID targetOID = new OID(".1.3.6.1.2.1.1.5");
> PDU pdu = new ScopedPDU();
> pdu.add(new VariableBinding(targetOID));
> pdu.setType(PDU.GETNEXT);
>
> ResponseEvent response = snmp.send(pdu,target);
> PDU responsePDU = response.getResponse();
> System.out.println(responsePDU.get(0));
> snmp.close();
> }
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

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




More information about the SNMP4J mailing list