net-snmp相关

        final TransportMapping transport = new DefaultUdpTransportMapping();
        final Snmp snmp = new Snmp(transport);
        final USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
        SecurityModels.getInstance().addSecurityModel(usm);
        transport.listen();
        // add user to the USM
        snmp.getUSM().addUser(
                new OctetString("hanxirui"),
                new UsmUser(new OctetString("hanxirui"), AuthMD5.ID, new OctetString("authpass123"), PrivDES.ID,
                        new OctetString("authpass456")));

        // create the target
        final UserTarget target = new UserTarget();
        final Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161");
        target.setAddress(targetAddress);
        target.setRetries(1);
        target.setTimeout(5000);
        target.setVersion(SnmpConstants.version3);
        target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
        target.setSecurityName(new OctetString("hanxirui"));

        // create the PDU
        final PDU pdu = new ScopedPDU();
        pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.5")));
        pdu.setType(PDU.GETNEXT);

        // send the PDU
        final ResponseEvent response = snmp.send(pdu, target);


http://blog.csdn.net/vastsmile/article/details/4535128
http://blog.csdn.net/vastsmile/article/details/4542999

你可能感兴趣的:(snmp)