HowTo play with SNMP

This mini HowTo is about how you can use SNMP client tools to retrieve human readable information from devices running an SNMP daemon. In the examples below mini-snmpd is used as the daemon and as client both the command line net-snmp tool and the snmpB GUI are used.

Personally I use both Ubuntu and Debian, so the tools I use to download the clients will reflect that. See your respective UNIX distro’s help pages for how to install these client tools in your operating system.

Installing SNMP in Ubuntu

The following command installs snmpset/get/walk, base MIBs and all standard MIBs needed.

sudo apt-get install snmp libsnmp-base snmp-mibs-downloader

Assuming you have already started mini_snmpd on your client, you should be able to do the following:

snmpwalk -v2c -c public
snmpget -c public -v 2c system.sysUpTime.0

If you experience problems, see Debian bug #561578 for details on how to edit and fix your system default /etc/snmp/snmp.conf

On my system I’ve had trouble getting net-snmp to use the UCD-SNMP-MIB, so I’ve added it explicitly to my ~/snmp/snmp.conf:


This MIB is in /usr/share/snmp/mibs/ on my system …

Installing Private MIB files

If you want to access a router/switch which uses private MIBs you can do the same as I did for the UCD-SNMP-MIB:

mkdir -p ~/.snmp/mibs
cp ALL-PRIVATE-MIBS ~/.snmp/mibs/`basename $file .my`
cat << EOF > ~/.snmp/snmp.conf
mibdirs /usr/share/snmp/mibs:/usr/share/mibs/ietf:/usr/share/mibs/iana:/usr/share/mibs/irtf:/usr/share/mibs/tubs:$HOME/.snmp/mibs

Now you should be able to do this:

snmpset -c private -v 2c COMPANY-SOME-MIB::reboot.0 i 1

which is quite an improvement over:

snmpset -c private -v 2c i 1

Useful Tests

Walk all IP addresses

snmpwalk -v2c -c public 

Get loadavg

snmpwalk -v2c -c public UCD-SNMP-MIB::laLoad

For more tips on using snmpwalk, see the Net-SNMP wiki