Hi, There are many possible causes:
* UDP buffer overflow * main task finishes too early * errors in your queuing stuff ... Regards, Frank On 16.03.2010 00:29, jctaboada wrote: > > > -------- Original Message -------- > Subject: processPdu does not receive all the traps > Date: Mon, 15 Mar 2010 20:22:52 +0800 > From: jctaboada<[email protected]> > To: "[email protected]"<[email protected]> > > Good day. > > Could someone help me why I cannot receive all the traps from my snmp > agent? > My snmp agent sends 27,000 traps to my manager but not all is received in > the manager there are losses. > I've been using wireshark to check if my manager receives the 27,000 traps > and tcmdump to check if my agent sends the 27,000 trap. > For both wireshark and tcpdump, trap count is 27,000. Only in processPdu > where all traps are not received. > > Please see my code below: > > public void initListen() throws UnknownHostException, IOException > { > logger_.debug("initListen start"); > > System.out.println("listen start"); > TransportMapping transport; > int version = 3; > USM usm = null; > MultiThreadedMessageDispatcher dispatcher; > ThreadPool threadPool; > > threadPool = ThreadPool.create("Trap", 1); > dispatcher = new MultiThreadedMessageDispatcher(threadPool, new > MessageDispatcherImpl()); > > // initialize trap listen port > transport = new DefaultUdpTransportMapping( > new UdpAddress("0.0.0.0/"+trapPort)); > > // session = new Snmp(transport); > // session.getMessageDispatcher().addMessageProcessingModel(new > MPv3()); > > if(localEngineID == null) > { > localEngineID = new OctetString(MPv3.createLocalEngineID()); > } > > // add usm to session for snmp version 3 > if (version == SnmpConstants.version3) > { > usm = new USM(SecurityProtocols.getInstance(), localEngineID, > 0); > > SecurityModels.getInstance().addSecurityModel(usm); > > // adds all users to the USM > UsmUser usmUser = null; > > // check security level for usm user > if (securityLevel == 0) > { > usmUser = new UsmUser( new OctetString(user), null, null, > null, null); > } > else if (securityLevel == 1 ) > { > usmUser = new UsmUser( new OctetString(user), AuthSHA.ID, > new OctetString(password), null, null); > } > else if ( securityLevel == 2 ) > { > usmUser = new UsmUser( new OctetString(user), AuthSHA.ID, > new OctetString(password), PrivAES128.ID, new OctetString(password)); > } > usm.addUser(usmUser.getSecurityName(), usmUser); > } > > System.out.println(usm.getUserTable().getUserEntries().toString()); > > dispatcher.addMessageProcessingModel(new MPv3(usm)); > SecurityProtocols.getInstance().addDefaultProtocols(); > > session = new Snmp(dispatcher, transport); > > // ((MPv3) session.getMessageProcessingModel(MPv3.ID)) > // .setLocalEngineID(localEngineID.getValue()); > > session.addCommandResponder(this); > > // initilize queue > logQueue = new LinkedBlockingQueue<CommandResponderEvent>(); > > try { > logger_.debug("listen start"); > // open port for trap > session.listen(); > System.out.println("Ready to accept notifications."); > } catch (UnknownHostException e1) { > e1.printStackTrace(); > logger_.error(e1); > logger_.debug("trap port fails"); > try > { > logger_.debug("closing session"); > session.close(); > } > catch (IOException e3) > { > e3.printStackTrace(); > logger_.debug("close session fails"); > logger_.error(e3); > } > } catch (IOException e1) { > e1.printStackTrace(); > logger_.error(e1); > logger_.debug("trap port fails"); > try > { > logger_.debug("closing session"); > session.close(); > } > catch (IOException e4) > { > e4.printStackTrace(); > logger_.debug("close session fails"); > logger_.error(e4); > } > } > logger_.debug("initListen end"); > } > > public synchronized void processPdu(CommandResponderEvent comEvent) > { > logger_.debug("processPdu start"); > > boolean flag = false; > > try > { > flag = logQueue.offer(comEvent); > successflag++; > System.out.println(successflag); > if(flag) > { > logger_.debug("offer success"); > } > else > { > logger_.error("offer fail"); > } > } > catch (NullPointerException e) > { > logger_.error(e); > logger_.debug("offer fail"); > } > > logger_.debug("processPdu end"); > } > > public void getFromQueue() > { > logger_.debug("getFromQueue start"); > > CommandResponderEvent event = null; > > PDU pdu = null; > > while(!logQueue.isEmpty()) > { > try > { > event = logQueue.take(); > logger_.debug("take end"); > } > catch (InterruptedException e) > { > logger_.debug("take fails"); > logger_.error(e); > } > > pdu = event.getPDU(); > > if(pdu != null) > { > if(logger_.isDebugEnabled()) > { > logger_.debug("pdu is not null"); > System.out.println("Trap received = " + > pdu.getVariableBindings()); > } > logger_.info(pdu.getVariableBindings()); > // logger_.info(event); > } > else > { > logger_.info("pdu is null"); > } > } > > logger_.debug("getFromQueue end"); > } > > Please give me some advice on how to fix this. > > Best regards, > > JC > _______________________________________________ > SNMP4J mailing list > [email protected] > http://lists.agentpp.org/mailman/listinfo/snmp4j -- AGENT++ http://www.agentpp.com http://www.snmp4j.com http://www.mibexplorer.com http://www.mibdesigner.com _______________________________________________ SNMP4J mailing list [email protected] http://lists.agentpp.org/mailman/listinfo/snmp4j
