![]() ![]() ![]() I've also tried replacing the MPv3.createLocalEngineId() with the actual engine id, but that didn't seem to help either. The code above doesn't generate any log messages on the snmptrapd server. Now I've ran the following code, and have confirmed it arrives at the VM(ran the snmptrapd command with -d enabled to see the snmp packet actually arrived) TransportMapping transportMapping = new DefaultUdpTransportMapping() Snmp snmp = new Snmp(transportMapping) OctetString localEngineId = new OctetString(MPv3.createLocalEngineID()) USM usm = new USM(SecurityProtocols.getInstance(), localEngineId, 0) SecurityModels.getInstance().addSecurityModel(usm) OctetString securityName = new OctetString("o2m-user") OID authProtocol = AuthSHA.ID OID privProtocol = PrivDES.ID OctetString authPassphrase = new OctetString("o2m-auth") OctetString privPassphrase = new OctetString("o2m-priv") snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase)) UserTarget target = new UserTarget() tSecurityLevel(SecurityLevel.AUTH_PRIV) tSecurityName(securityName) tAddress(new UdpAddress("192.168.1.92" + "/" + 162)) tVersion(SnmpConstants.version3) snmp.listen() ScopedPDU pdu = new ScopedPDU() pdu.setType(PDU.TRAP) pdu.setContextEngineID(localEngineId) pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(1))) pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(".1.3.6.1.2.1.1.8"))) ("Sending V3 trap") nd(pdu, target) snmp.close() On the VM it generates this log message: 14:42:21 :44309-> :162]: DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1) 0:00:00.01 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-MIB::sysORLastChange I've tried my settings with the following command, confirming it worked: V3 messages are received but are not processed when send from Java.VM on debian 9(Stretch) (192.168.1.92) running snmptrapd ![]() I'd like to add support for V2 and V3 traps with authentication.ĭev machine running the notifier. The traps/notify's are meant to be sent to a remote listener. I'm trying to create a SNMP TRAP/Notify agent in Java using SNMP4J. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |