[SNMP4J] Sending v2 and v3 SNMP traps

Frank Fock fock at agentpp.com
Mon Aug 8 09:05:20 CEST 2005


Hi,

v2c notifivations do not have the snmpTrapEnterprise and
snmpTrapAddress fields. The first two variable bindings must
be sysUpTime.0 and snmpTrapOID.0.

Best regards,
Frank


Keary Parinis wrote:

>Hi,
>
>I went through the console tools and SNMP class documenation.  I am able
>to send SNMP version 1 traps to HP Openview w/out a problem.  I can't
>seem to get SNMP v2 traps to send.  I pasted my code at the bottom of
>this message.  Does anyone have a good example of sending v2 and v3
>traps?  Thanks.
>
>TransportMapping transport = new DefaultUdpTransportMapping();
>Snmp snmp = new Snmp(transport);
>CommunityTarget cTarget = new CommunityTarget();
>cTarget.setAddress(target);
>cTarget.setCommunity(new OctetString("public"));
>cTarget.setRetries(2);
>cTarget.setTimeout(1500);
>cTarget.setVersion(SnmpConstants.version2c);
>snmp.listen();
>PDU pduV2 = new PDU();
>pduV2.add(new VariableBinding(SnmpConstants.snmpTrapEnterprise, new OID
>("1.3.6.1.4.1.37")));
>pduV2.add(new VariableBinding(SnmpConstants.snmpTrapAddress));
>pduV2.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID
>("1.3.6.1.4.1.37.0.78")));
>pduV2.add(new VariableBinding(SnmpConstants.snmpTrapCommunity, new
>OctetString("public")));
>pduV2.add(new VariableBinding(new OID("1.3.6.1.4.1.37.0.78"), new
>OctetString("Version 2 Trap")));
>pduV2.setType(PDU.TRAP);
> //this response returns null
>ResponseEvent response = snmp.send(pduV2,cTarget, transport);
>System.out.println(pduV2);
>System.out.println(response);
>snmp.close();
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>  
>


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





More information about the SNMP4J mailing list