[SNMP4J] receiving traps

Liav Elias lelias at allot.com
Sun Sep 26 14:34:51 CEST 2004


Hi Frank,

I will do it from next time ...
you were correct it was because of failed security.

thanks you,
Liav
-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com]
Sent: Thu, September 23, 2004 4:53 PM
To: Liav Elias
Cc: SNMP4J at agentpp.org
Subject: Re: [SNMP4J] receiving traps


Hi Liav,

You can (have to) use the same method. You probably do not receive
v3 traps because of failed security (you can set the log4J log level to
DEBUG to trace this). To enable security you will have to add the
following lines before the "transport.listen()" call:

 MPv3 mpv3 =
      (MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
 USM usm = new USM(SecurityProtocols.getInstance(),
                   new OctetString(mpv3.createLocalEngineID()), 0);
  SecurityModels.getInstance().addSecurityModel(usm);
 
and here you will have to add appropriate USM user information to
the USM.addUser method.

Best regards,
Frank

P.S.: The SNMP4J mailing list settings require that you use the "Reply all"
button of your mailer to reply to the list.


Liav Elias wrote:

>Hi Frank,
>
>When I use V1 Trap the method processPdu(CommandResponderEvent e) is called
>but when I use V3 traps this 
>method is not called when a trap arrives. my question is what method/class
>should I implement in order to catch
>the V3 traps?
>
>thanks for the help,
>Liav
>
>-----Original Message-----
>From: Frank Fock [mailto:fock at agentpp.com]
>Sent: Wed, September 22, 2004 11:41 PM
>To: Liav Elias
>Cc: 'snmp4j at agentpp.org'
>Subject: Re: [SNMP4J] receiving traps
>
>
>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