Half-Blood Programmer

Trident Sign: How to Set Up SNMP4J Agent, Part 1

To enrich #SNMP v3 support, I am going to use snmp4j agent. But due to lack of documentation for me, a Java blind, I have to learn about it bit by bit.
Below is a summary of my steps,
  1. Download and install Java runtime from http://java.com. I install it to C:\Program Files (x86)\Java\jre6.
  2. Configure JAVA_HOME like this (http://wso2.org/project/wsas/java/1.1/docs/setting-java-home.html) and add C:\Program Files (x86)\Java\jre6\bin to PATH.
  3. Download snmp4j agent ZIP package from here (http://snmp4j.org/html/download.html). I use 1.3.1 version.
  4. Unzip this package and copy all JARs from “lib” to “dist\lib”.
  5. Create a launch.bat in “dist\lib” and use the following content.
  6. Execute this batch file to launch the agent. To stop it, simply close the console window.
Batch file content is,
    java -cp SNMP4J-agent.jar;SNMP4J.jar;log4j-1.2.9.jar org.snmp4j.agent.test.TestAgent
I will spend more time on this agent and post future findings later.

4 thoughts on “Trident Sign: How to Set Up SNMP4J Agent, Part 1

  1. Cassanova

    Thank you for this detailed tutorial.. It has helped me a lot. Since you have a quite interesting experience with Snmp, I have few questions that I hope you can help with.

    I used the Sample code given in the package to retrieve some information from the Windows snmp agent. I used “Getif” as an MIB browser and the application could retrieve some valuable information as the Routing table..etc
    I copied the corresponding OID of routing table and pasted it to my code. but I was surprised to get an exception :
    ” Exception during SNMP operation: snmp.SNMPGetException: OID not available for retrieval”
    (the OID is of the ipforwardDest in ipforwardtable)

    but when I select the OID of an instance given back by Getif and paste it to my code I get a answer as
    I get this answer :
    “Thread 831: Retrieving value corresponding to OID
    Thread 831: Retrieved value: type snmp.SNMPIPAddress, value″

    So what do you suggest to get the whole routing table ? should I implement an Ip counter ??

  2. Cassanova

    I found it.. I should use a specific function to get table form MIB…

    Thank you anyway.. your article was helpful to locate the problem.

    If you have anything about SNMP and web monitoring I’ll be very grateful if you share it.

    1. Andres

      Hello friend, I have the same problem will be that could help me. I’m trying to return the same MIB you commented, routing table …

Leave a Reply