[SNMP4J] need help sending a trap
Jeff Ramin
ramin at berbee.com
Mon Jun 2 22:30:57 CEST 2008
Hi folks.
I want to send a trap, and I'm not interested in receiving
a response.
My current code:
snmp = new Snmp(new DefaultUdpTransportMapping());
PDU trap = new PDU();
trap.setType(PDU.TRAP);
OID oid = new OID("1.2.3.4");
trouble-> oid.setValue("some string");
trap.add(new VariableBinding(oid));
Address targetaddress = new UdpAddress(address + "/" + port);
CommunityTarget target = new CommunityTarget();
target.setCommunity("public");
target.setVersion(SnmpConstants.version2c);
target.setAddress(targetaddress);
snmp.send(trap, target, null, null);
I think I'm using the OID object incorrectly - if I remove the line labeled
"trouble", things seem to work properly. I see a trap with OID of 1.2.3.4
and a value of null. When I try to set the value, it seems to destroy the
OID; the oid in the packet capture becomes "0.0", and the value is null.
What am I doing wrong? Thanks!
--
Jeffrey Ramin
Berbee
ramin at berbee.com
608.298.1024
More information about the SNMP4J
mailing list