PDU pdu = new PDU();
pdu.setType(PDU.SET);
pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.100.1.1"), new Counter64(System.currentTimeMillis())));
pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.100.2.1"), new OctetString("some string")));
TransportMapping transport = null;
Snmp snmp = null;
try {
transport = new DefaultUdpTransportMapping();
transport.listen();
snmp = new Snmp(transport);
snmp.send(pdu, getCommunityTarget());
} catch (Exception e) {
// error occurred
}
This is how I send my snmp trap to raise alarm. I'm setting a varible in snmp agent and browse it in MIB browser. I want to know that what if I set pdu type as PDU.TRAP. It works on port 162 rather than 161 and I cannot see it MIB browser but in Trap Receiver. What is the difference? What is the aim of using PDU.TRAP? How can my agent catch it? What is the best practice to raise and clear alarms?