[SNMP4J] Usm_Stats_Not_In_Time_Window problem in SNMP4j

Jochen Katz katz at agentpp.com
Wed Nov 10 21:51:14 CET 2010


Hi,

with the following changes I can see that the default ReportHandler of
Snmp class can be overridden. Maybe you are setting your report handler
on one Snmp object and use another one (with default handler) to send
the request.

# svn diff -x -w
Index: src/org/snmp4j/tools/console/SnmpRequest.java
===================================================================
--- src/org/snmp4j/tools/console/SnmpRequest.java       (Revision 1881)
+++ src/org/snmp4j/tools/console/SnmpRequest.java       (Arbeitskopie)
@@ -50,6 +50,16 @@
     BER.setCheckSequenceLength(false);
   }

+
+public class SnmpReportHandler implements Snmp.ReportHandler{
+
+    public void processReport(PduHandle pduhandle,
CommandResponderEvent event)
+    {
+        System.err.println("In processReport");
+    }
+}
+
+
   public static final int DEFAULT = 0;
   public static final int WALK = 1;
   public static final int LISTEN = 2;
@@ -278,6 +288,7 @@
     SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());

     Snmp snmp = new Snmp(mtDispatcher, transport);
+       snmp.setReportHandler(new SnmpReportHandler());
     if (version == SnmpConstants.version3) {
       USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);
       SecurityModels.getInstance().addSecurityModel(usm);
@@ -325,6 +336,7 @@
     // Could save some CPU cycles:
     // transport.setAsyncMsgProcessingSupported(false);
     Snmp snmp =  new Snmp(transport);
+       snmp.setReportHandler(new SnmpReportHandler());
     ((MPv3)snmp.getMessageProcessingModel(MPv3.ID)).
         setLocalEngineID(localEngineID.getValue());


# java -cp dist/lib/SNMP4J.jar:lib/log4j-1.2.14.jar
org.snmp4j.tools.console.SnmpRequest -d DEBUG -a MD5 -A
MD5UserAuthPassword -u MD5 -p GETNEXT 127.0.0.1/4700
In processReport
In processReport
Received response after 2008 millis
Request timed out.

Regards,
  Jochen


Am 09.11.2010 07:52, schrieb Jigar Shah:

> I have generated Report UsmStatsNotInTimeWindow from agent side to manager side.
> 
> Can u pls answer some of my doubts
> 
> 1) When I will get Report on manager side, Which API will be used at manager side (Which method will be called)  ??
> 
> 2) If I want to handle this report explicitly, which interface should I implement and where should I register that interface.
> 
> 
> 
> I have done this thing.... but problem is this class is not getting called wen I get Report.



More information about the SNMP4J mailing list