How to configure SNMP in mininet

First, you need to install snmp on your system:

sudo apt-get install snmp snmpd

Now, procced to configure snmp with the respective information about your machine:

sudo mv /etc/snmp/snmpd.conf  /etc/snmp/snmpd.conf.org
sudo vim /etc/snmp/snmpd.conf
#Add these lines
#Change public by your SecretPassword if you like
rocommunity  public
syslocation  "Somewhere"
syscontact  nicolas.boettcher@mail.udp.cl

Now, edit the snmp daemon to listen all interfaces:

sudo vim /etc/default/snmpd
Change from:
# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

To:
# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

Now, restart the daemon with:

 /etc/init.d/snmpd restart

To check it's all ok, run this follow command:

snmpwalk -v1 -c public 127.0.0.1:161

If you want to use MIB filters like system, probably you will get this error:

snmpwalk -Dparse-mibs  -v1 -c public 127.0.0.1:161 system
parse-mibs: No index
parse-mibs: cannot open MIB directory /usr/share/mibs/netsnmp
system: Unknown Object Identifier (Sub-id not found: (top) -> system)

You can try downloading all mibs with this command:

sudo apt-get install snmp-mibs-downloader
sudo echo 'mibs +ALL' >> /etc/snmp/snmp.conf
/etc/init.d/snmpd restart

Now, you can see the OID (object ID) and show the full list with:

snmptranslate -Tp

However, you can use the identificator .1.3.6.1.2.1.1, instead of system, as follows:

snmpwalk -v1 -c public 127.0.0.1:161 .1.3.6.1.2.1.1

Now, to test SNMP on mininet, proceed to download and run the following test file:

wget https://raw.githubusercontent.com/kspviswa/py-playground/master/snmpTest.py
sudo python snmpTest.py

Just execute the following line on every host throught xterm to run snmpd:

/usr/sbin/snmpd -Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf


Reference: https://kspviswa.wordpress.com/2015/06/20/how-to-run-snmp-agents-clients-inside-mininet-hosts/





Comments

Popular posts from this blog

from: can't read /var/mail/ in Python scripts

How to fix Android when developer options are not available for this user

How to install a WhatsApp bot based on Python