Skip to content

Instantly share code, notes, and snippets.

@mattie47
Last active November 1, 2019 09:17
Show Gist options
  • Save mattie47/78e623ffed2fa3455ddc1d8aec20a9bb to your computer and use it in GitHub Desktop.
Save mattie47/78e623ffed2fa3455ddc1d8aec20a9bb to your computer and use it in GitHub Desktop.
Attached are some instructions for getting snmpsim working.

snmpsim Installation

snmpsim is built on python and requires several other python libraries.

Prerequisites

apt install python-pip
pip install virtualenv
/usr/bin/easy_install virtualenv

Install

source venv/bin/activate
pip install snmpsim

If you don't have python-virtualenv installed

sudo apt-get install python-virtualenv

Actually this may have done it:

First, install Virtualenv:

sudo apt-get install python-virtualenv

Then Create Virtualenv:
virtualenv venv #venv is name

For activating virtualenv.First, move to folder, In which you want to enable and run this command:
source venv/bin/activate

Once, Your work is done then disable virtualenv:
deactivate

From <https://stackoverflow.com/questions/43982761/pythons-virtualenv> 

I had issues with the snmpsim I'd installed. It helped to uninstall it, then reinstall it:

Sudo pip uninstall snmpsim
Sudo pip install snmpsim

Now things just seem to be working….

Running SNMP sim

librenms@librenmsdev:~$ source venv/bin/activate
(venv) librenms@librenmsdev:~$ ./scripts/collect-snmp-data.php --snmpsim

This will start up the server.

OR

librenms@librenmsdev:~$ source venv/bin/activate
snmpsimd.py --data-dir=./test/data --agent-udpv4-endpoint=127.0.0.1:1024

From <http://snmplabs.com/snmpsim/quickstart.html#run-the-simulator> 

LibreNMS Workflow

	- Run ./scripts/collect-snmp-data.php -h <host> -m os, initial snmprec will be created
	- If there is additional snmp data required, run ./scripts/collect-snmp-data.php -h 42 -m os
	- Run ./scripts/save-test-data.php -o example-os -m os to update the dumped database data.
	- Review data. If you modified the snmprec or code (don't modify json manually) run �            ./scripts/save-test-data.php -o example-os -m os
	- Run 
	- If the tests succeed submit a pull request
Additional module support or test data
	1. Add code to support module or support already exists.
	2. ./scripts/collect-snmp-data.php -h 42 -m <module>, this will add more data to the snmprec file
	3. Review data. If you modified the snmprec (don't modify json manually) run ./scripts/save-test-data.php -o example-os -m <module>
	4. Run ./scripts/pre-commit.php --db --snmpsim
	5. If the tests succeed submit a pull request

From <https://docs.librenms.org/Developing/os/Test-Units/#tests> 

Simulating a node:

librenms@librenmsdev:~$ source venv/bin/activate
(venv) librenms@librenmsdev:~$ snmpsimd.py --data-dir=/opt/librenms/tests/snmpsim/ --agent-udpv4-endpoint=127.0.0.1:1161
librenms@librenmsdev:~$ cat /etc/hosts | grep local
127.0.0.1 localhost snmpsim
librenms@librenmsdev:~$  ./addhost.php snmpsim cimc v2c 1161
librenms@librenmsdev:~$ ./discovery.php -h snmpsim -d
librenms@librenmsdev:~$ ./poller.php -h snmpsim -d

Generate json test data

librenms@librenmsdev:~$ source venv/bin/activate
(venv) librenms@librenmsdev:~$ ./scripts/save-test-data.php -o awplus
Starting snmpsim listening on 127.1.6.1:1161... 
OS: awplus
Module: all

Added device: 54
127.1.6.1 54 awplus 

#### Load disco module core ####

>> Runtime for discovery module 'core': 0.0160 seconds with 1192 bytes
>> SNMP: [6/2.97s] MySQL: [26/0.04s] RRD: [0/0.00s]
#### Unload disco module core ####


#### Load disco module os ####
OS: Alliedware Plus (awplus)
Changed Icon! : alliedtelesis.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment