[SNMP4J] receiving traps
Frank Fock
fock at agentpp.com
Wed Sep 22 23:41:01 CEST 2004
Hi Liav,
The SnmpRequest class is only *an example*. Please use the
org.snmp4j.Snmp class for your SNMP programming. See also
the UML diagramm at:
http://www.snmp4j.org/UMLClassOverview/UMLClassOverview.htm
For SNMPv1/v2c trap receiption the following code is sufficient:
Address targetAddress =
GenericAddress.parse("udp:0.0.0.0/162");
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
CommandResponder trapPrinter = new CommandResponder() {
public synchronized void processPdu(CommandResponderEvent e) {
PDU command = e.getPdu();
if (command != null) {
System.out.println(command.toString());
}
}
};
snmp.addCommandResponder(trapPrinter);
transport.listen();
Hope this helps.
Best regards,
Frank
Liav Elias wrote:
>Hi all,
>
>I am using snmp4j in order to receive traps. I have 2 questions about this
>issue:
>
>1. I am using the class org.snmp4j.tools.console.SnmpRequest in order to
>listen to traps. I succeed to receive the traps (I see output in the console
>for each trap), how can I process the incoming trap, for example to receive
>all the data that was sent with the trap? do I need to implement a certain
>class in order to take care of that?
>2. Is this the correct way to implement listing to traps in my application?
>I mean with the console class SnmpRequest (calling this class with args[])?
>or do I need to implement other classes in order to use a listener for the
>incoming traps and to process them?
>thanks,
>Liav
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
>
>
More information about the SNMP4J
mailing list