[SNMP4J] Sending v2 and v3 SNMP traps

Keary Parinis kpc7335e at yahoo.com
Mon Aug 8 08:39:06 CEST 2005


Deon,

You're right.  I did realize later that I should not expect a response
from a trap.  My v1 traps go fine and provide a null response.  

All,

I'm still working on getting v2 traps to work.  Once I get v2 down, I'll
start working on v3.  Any examples of v2 and v3 traps would be a big
help.  Thanks.
> Hi,
> 
> I have also just been using v1 and started looking at 2c just this
> morning... So mine is not working yet...
> 
> You are expecting/waiting for a response to the TRAP.  Should you not be
> using the TRAP.INFORM pdu type then?
> 
>   pduV2.setType(PDU.INFORM);
> 
> 
> > -----Original Message-----
> > From: snmp4j-bounces at agentpp.org 
> > [mailto:snmp4j-bounces at agentpp.org] On Behalf Of Keary Parinis
> > Sent: Monday, August 08, 2005 04:30
> > To: snmp4j at agentpp.org
> > Subject: [SNMP4J] Sending v2 and v3 SNMP traps
> > 
> > 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
> > 
> 
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list