Wiki source code of How do I create an agent (or snmp simulator) using a "MIB walk"?
Last modified by Frank Fock on 2024/05/25 12:38
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | With SNMP4J and SNMP4J-Agent you can create a simulation agent from a real agent in two steps: | ||
| 2 | |||
| 3 | ==== 1. Create a MIB walk snapshot file ==== | ||
| 4 | |||
| 5 | A snapshot file can be created with [[SNMP4J-CLT>>url:https://doc.snmp.app/display/SNMP4J/SNMP4J-CLT-Usage]], [[SNMP4J>>url:http://www.snmp4j.org/]], and [[MIB Explorer Pro>>url:http://www.mibexplorer.com/]]. The following examples illustrate the commands necessary to save a snapshot file with SNMP4J-CLT from an agent that listens on the //localhost// interface on port //161//: | ||
| 6 | |||
| 7 | {{code}} | ||
| 8 | java -jar SNMP4J-CLT.jar -v 2c -c public create-snapshot /tmp/mibdump.sf 127.0.0.1/161 1.3.6 | ||
| 9 | {{/code}} | ||
| 10 | |||
| 11 | With MIB Explorer Pro, you can use the MIB browser GUI to walk a subtree (or several independent subtrees, even from different agents) and combine those variables into a snapshot file. You can also compare snapshot files and view their content. | ||
| 12 | |||
| 13 | _Note: To use a snapshot file stored by MIB Explorer Pro with SNMP4J-Agent, you need to convert it into the SNMP4J snapshot format first. For MIB Explorer 2.x snapshot files download the converter from [[https:~~/~~/agentpp.com/tools/mibexplorer/SnapshotConv.jar>>url:https://agentpp.com/tools/mibexplorer/SnapshotConv.jar]] and run it with: | ||
| 14 | |||
| 15 | {{code}} | ||
| 16 | java -jar SnapshotConv.jar [-h] <mibexplorer-snaphost-file> <snmp4j-snapshot-file> | ||
| 17 | {{/code}} | ||
| 18 | |||
| 19 | ==== 2. Run the SNMP4J-Agent Snapshot-Agent with the created file ==== | ||
| 20 | |||
| 21 | The following command line starts an agent listening on all interfaces on port //4700// which is provides the MIB variables collected in the file **/tmp/mibdump.sf**: | ||
| 22 | |||
| 23 | {{code}} | ||
| 24 | java -cp SNMP4J-agent.jar;SNMP4J.jar org.snmp4j.agent.test.SnapshotAgent /tmp/mibdump.sf 0.0.0.0/4700 | ||
| 25 | {{/code}} | ||
| 26 | |||
| 27 | This agent can be then browsed using SNMP4J-CLT with: | ||
| 28 | |||
| 29 | {{code}} | ||
| 30 | java -jar SNMP4J-CLT.jar -v 2c -c public walk 127.0.0.1/4700 1.3.6 | ||
| 31 | {{/code}} |