[SNMP4J] problem to receive traps
Frank Fock
fock at agentpp.com
Mon Jun 12 15:03:26 CEST 2006
Hello Stefan,
Stefan M wrote:
>> Hello Stefan,
>>
>> You did not specify the interface and port on which you want
>> to receive SNMP messsages. SNMP4J therefore chooses an arbitrary
>> one. Have you sent the traps to that port?
>>
>> If you have used
>>
>> this.snmp = new Snmp(new DefaultUdpTransportMapping());
>>
>> by accident, then please specify the port like this
>
> Hello Frank,
>
> I am using this snmp object to send snmp messages as well. Hope this is
> no problem? If I specifiy an Address as you do, I get a null pointer
> exception when trying to send a message...but maybe this is due to
> privileges on my machine... Will try it and send my results. Thanks for
> this great package and support!
>
> Stefan
If you also want to send SNMP messages as well, then
I would recommend that you use your existing code and
add the marked line:
...
this.snmp = new Snmp(new DefaultUdpTransportMapping());
CommandResponder trapPrinter =
new CommandResponder() {
public synchronized void processPdu(CommandResponderEvent e) {
LOGGER.debug("e = "+e);
PDU command = e.getPDU();
if (command != null) {
LOGGER.debug("TRAP>> "+command);
}
}
};
// -->>>> add this line to register your trap receiver:
this.snmp.addNotificationListener(
new UdpAddress("0.0.0.0/162", trapPrinter));
// -->>>> replaced by above line:
// snmp.addCommandResponder(trapPrinter);
this.snmp.listen();
...
Best regards,
Frank
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list