[SNMP4J] Process PDU not catching messages

Frank Fock fock at agentpp.com
Mon Mar 23 23:59:03 CET 2009


Hi Donna,

Use the Snmp.addNotificationListener instead to process
notifcations and traps. For INFORMs, SNMP4J will send
the response, because this is required by the SNMP standard.

Best regards,
Frank

Donna Griffin wrote:
> Hi there,
> 
> I have created a listener class called trapDump that implements the
> commandResponder interface and adds the unimplemented method,
> processPDU. However when the class recieves a trap or inform message
> it automatically generates a response message to the sender but does
> not print the print out statements in the method.
> 
> Please find the code attached below@
> 
> 
> private void registerForTraps(int port, String community, int version)
> 	throws IOException
> 	
> 	{    	
> 	AbstractTransportMapping transport;
> 		
> 		address=GenericAddress.parse("udp:127.0.0.1/" + port);
> 	    if (address instanceof TcpAddress) {
> 	      transport = new DefaultTcpTransportMapping((TcpAddress) address);
> 	    }
> 	    else {
> 	      transport = new DefaultUdpTransportMapping((UdpAddress) address);
> 	    }
> 	    ThreadPool threadPool =
> 	        ThreadPool.create("DispatcherPool", numDispatcherThreads);
> 	    MessageDispatcher mtDispatcher =
> 	        new MultiThreadedMessageDispatcher(threadPool, new
> MessageDispatcherImpl());
> 	
> 	    // add message processing models
> 	    mtDispatcher.addMessageProcessingModel(new MPv1());
> 	    mtDispatcher.addMessageProcessingModel(new MPv2c());
> 	    mtDispatcher.addMessageProcessingModel(new MPv3(localEngineID.getValue()));
> 
> 	    // add all security protocols
> 	    SecurityProtocols.getInstance().addDefaultProtocols();
> 
> 	    Snmp snmp = new Snmp(mtDispatcher, transport);
> 	    if (version == SnmpConstants.version3) {
> 	      USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);
> 	      SecurityModels.getInstance().addSecurityModel(usm);
> 	      if (authoritativeEngineID != null) {
> 	        snmp.setLocalEngine(authoritativeEngineID.getValue(), 0, 0);
> 	      }
> 	      // Add the configured user to the USM
> 	      snmp.getUSM().addUser(new OctetString(securityName), new
> UsmUser(new OctetString(securityName),
> 					authType,
> 					new OctetString(authPassword),
> 					privType,
> 					new OctetString(privPassword)));	    }
> 	    else {
> 	      CommunityTarget target = new CommunityTarget();
> 	      target.setCommunity(new OctetString(community));
> 	      this.target = target;
> 	    }
> 		
> 	
> 	    snmp.addCommandResponder(this);
> 	    transport.listen();
> 	    System.out.println("Listening on "+address);	
> 	}
> 
> 
> public void processPdu(CommandResponderEvent arg0) {
> 		// TODO Auto-generated method stub
> 		System.out.println("inside processPdu..." + arg0.getPDU());
> 	}
> 
> What I would expect now is that when the agent recieves the trap or
> INFORM message the processPDU method would be called but it is not. I
> also ran the examples that came with the distribution and the
> statements in the processPDU method is not called there either Can you
> help me please!
> 
> Regards,
> Donna
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list