[SNMP4J] Sending custom message SNMP V2C Trap using Java

Kaviarasu P kaviarasu.p at servion.com
Thu Sep 2 12:59:39 CEST 2010


 
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.






More information about the SNMP4J mailing list