[SNMP4J] IP in Trap code

Debakanta Behera bdebakanta at gmail.com
Tue Jul 3 12:52:45 CEST 2007


 Hi  everybody
Iam new to snmp......
 could anyone send the trap code witch only receive trap that are comming
from any snmp-device.
I have the trap code ,but this is not working......


*import* org.snmp4j.*;

*import* org.snmp4j.smi.*;

*import* org.snmp4j.transport.*;

*public* *class* RTrapV2 *implements* CommandResponder{

 TransportMapping transport;

 Snmp snmp;

  *public* RTrapV2(){

  *try*{

  transport = *new* DefaultUdpTransportMapping(*new
*UdpAddress("10.10.30.93/162/*thisis the IP of what? my machineIP or
deviceIP*/"
));

  snmp = *new* Snmp(transport );

  snmp.addCommandResponder(* this*);

  System. *out*.println( "transportBinding..");

  transport.listen();

  } *catch*(Exception e){e.printStackTrace();}

 }

  *public* *synchronized* *void* processPdu(CommandResponderEvent cmdREvent)
{

     System.*out*.println( "----Received Response -----");

     PDU pdu=cmdREvent.getPDU();

    }

  *public* *static* *void* main(String[] args)

 {

  RTrapV2 trp= *new* RTrapV2();



 }}



More information about the SNMP4J mailing list