HI all, I facing one problem tht getting response always null
I tried following code, when I print response that shows me null but if I
run this code & check in the runnig tool on my machin i.e in trap receiver I
able to seen mag
But I want to handle response programmatically but it showing me null
Address targetAddress = GenericAddress.parse("udp:"
+ "localhost"
+ "/162");
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(targetAddress);
target.setRetries(1);
target.setTimeout(2000);
target.setVersion(SnmpConstants.version1);
PDUv1 pdu1 = new PDUv1();
pdu1.setGenericTrap(PDUv1.COLDSTART);
pdu1.setSpecificTrap(Integer.parseInt(("0")));
pdu1.setEnterprise(new org.snmp4j.smi.OID());
//pdu1.setEnterprise(new OID(".1.3.6.1.2.1.1.1.0"));
pdu1.setType(PDUv1.V1TRAP);
VariableBinding vb = new VariableBinding();
vb.setOid(new OID(".1.3.6.1.2.1.1.1.0"));
vb.setVariable(new OctetString("This is just test
trap"));
pdu1.add(vb);
//pdu1.addOID(new VariableBinding(new
OID("1.3.6.1.2.1.1.1.0")));
try {
//IpAddress sourceIp = new
IpAddress("10.77.200.82");
IpAddress sourceIp = new
IpAddress(InetAddress.getLocalHost());
pdu1.setAgentAddress(sourceIp);
//System.out.println("so PDU
is......."+pdu1);
DefaultUdpTransportMapping
udpTransportMap = new DefaultUdpTransportMapping();
udpTransportMap.listen();
Snmp snmp = new Snmp(udpTransportMap);
ResponseEvent response = snmp.send(pdu1,
target,udpTransportMap);
System.out.println("SnmpNotificationTrap
: pdu1: " + pdu1);
System.out.println("SnmpNotificationTrap
: response: " + response.getSource());
snmp.close();
}
catch (Exception e) {
e.printStackTrace();
}
Thanks
Shweta
DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the
property of Persistent Systems Ltd. It is intended only for the use of the
individual or entity to which it is addressed. If you are not the intended
recipient, you are not authorized to read, retain, copy, print, distribute or
use this message. If you have received this communication in error, please
notify the sender and delete all copies of this message. Persistent Systems
Ltd. does not accept any liability for virus infected mails.
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j