[SNMP4J] Sending custom message SNMP V2C Trap using Java

Frank Fock fock at agentpp.com
Thu Sep 2 18:09:55 CEST 2010


Hi,

A trap/notification has never a response.

Best regards,
Frank

On 02.09.2010 12:59, Kaviarasu P wrote:
>
> Hi
>
> I'm new to SNMP4J
>
> I want to send the user defined events to Opennms Server from my application.
>
> I tried with the code below .
>
>
>   TransportMapping transport = new DefaultUdpTransportMapping();
> 			             Snmp snmp = new Snmp(transport);
> 			             snmp.listen();
> 			
> 			             CommunityTarget target1 = new CommunityTarget();
> 			             target1.setCommunity(new OctetString("public"));
> 			             target1.setAddress(new UdpAddress("192.168.1.151/162"));
> 			             target1.setVersion(SnmpConstants.version2c);
>
> 			             PDU request = new PDU();
> 			             request.setType(PDU.TRAP);
> 			             request.add(new VariableBinding(new OID("1.3.6.1.2.1.1.3.0"), new Integer32(0)));
> 			             request.add(new VariableBinding(new OID("1.3.6.1.6.3.1.1.4.1.0"), new OID("1.3.7")));
> 			             request.add(new VariableBinding(new OID("1.3.6"), new OctetString("Application error")));
>
> 			             ResponseEvent response = snmp.send(request, target1);
> System.out.println(request.getErrorStatus()); --->0
> System.out.println(target1.getAddress());--->192.168.1.151/162
> System.out.println(target1.getCommunity());----->public
> System.out.println(target1.getVersion());---->1  (I have set the version as 2 but i getting the o/p as 1)
> System.out.println(response);----->  null.
>
>
> I'm getting null as response.
>
>
> How to send the custum error message from my java application to OPennms Server .
> What OID should be used to send custom error message.
>
> kaviarasu.p at servion.com
>
> Thanks&  Regards
> P. Kaviarasu |Senior Software Engineer - CDO
> T: +91 44 6108 4100 | Ext:4553 | F: +91 44 6108 4101
> ________________________________________
>
>   The information contained in this e-mail message or messages (which includes any attachments) is confidential and may be legally privileged. It is intended only for the use of the person or entity to which it is addressed.
>
>
>
> _______________________________________________
> 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