flamenco
flamenco

Reputation: 2840

Simulate an SNMP agent using snmpsim

My goal is to simulate an agent using snmpsim from snmpsim. In that respect I walked an SNMP device and captured the output in a file, mydevice.snmprec. According to the instruction from snmpsim, I suppose to start the agent invoking snmpsimd.py --agent-udpv4-endpoint=127.0.0.1:1161. The problem is that this command does not point to mydevice.snmprec. Any idea how include mydevice.snmprec as part of the command to simulate the agent?

Upvotes: 1

Views: 6343

Answers (2)

flamenco
flamenco

Reputation: 2840

Just is case someone might come across the same issue, here is what I did to simulate the agent and the manager:

  1. Installed net-snmp via port install net-snmp for CLI manager. Also got a MIB Broswer for MAC.
  2. Installed snmpsim to simulate the agent
  3. Capture the OID from an actual device:

sudo snmprec.py --agent-udpv4-endpoint=10.1.1.10 --start-oid=1.3.6.1.4.1 --stop-oid=1.3.6.1.4.30 --use-getbulk  --output-file=snmpsim/data/mydevice.snmprec

  1. Open a terminal window and started the simulated agent:

    $ pwd
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snmpsim-0.2.4-py2.7.egg/snmpsim

    $ ls
    __init__.py	confdir.pyc	data		grammar		record
    __init__.pyc	daemon.py	error.py	log.py		variation
    confdir.py	daemon.pyc	error.pyc	log.pyc




    $ tree
    .
    ├── __init__.py
    ├── __init__.pyc
    ├── confdir.py
    ├── confdir.pyc
    ├── daemon.py
    ├── daemon.pyc
    ├── data
    │   ├── mydevice.snmprec
    │   ├── foreignformats
    │   │   ├── linux.snmpwalk
    │   │   ├── winxp1.snmpwalk
    │   │   └── winxp2.sapwalk


$ snmpsimd.py --data-dir=data --agent-udpv4-endpoint=127.0.0.1:1161

You should see something like these which represent the last lines where the agent is waiting for queries:

……………
………………..
………….
SNMPv3 USM SecurityName: simulator
SNMPv3 USM authentication key: auctoritas, authentication protocol: MD5
SNMPv3 USM encryption (privacy) key: privatus, encryption protocol: DES
Listening at UDP/IPv4 endpoint 127.0.0.1:1161, transport ID 1.3.6.1.6.1.1.0

  1. Open another terminal window to run the Manager:

$ snmpwalk -On -v2c -c mydevice 127.0.0.1:1161 .1.3.6.1.4.1 At this point you should see the agent reacting to the query and manager displaying whatever the agent sends back. Also, you can do the same thing from a MIB browser manager. Note: This supports read-only operations! I haven't got the part where one can write to the simulated agent, yet. I will post it if I can get it working.

Upvotes: 2

McDowell
McDowell

Reputation: 108949

Usually you would put it in ~/.snmpsim/data but there is also a --data-dir switch.

You should see some output like this telling you the community name:

Configuring /home/someuser/.snmpsim/data/foo.snmprec controller
SNMPv1/2c community name: foo

Upvotes: 2

Related Questions