SNMP stands for Simple Network Management Protocol. The 'simple' refers more to 'protocol' than to "Network Management'. But anyway ...
This is not a tutorial on SNMP, but rather a very basic introduction on how to use SNMP on a Linux system (Debian/Ubuntu oriented). I'll assume that you know that SNMP exposes data about a system in the form of variables and that these variables can then be queried (and sometimes set) with software tools. The SNMP protocol provides the mechanism, but does not discribe what data a system should expose. The latter is described by MIBs, "Management Information Base". A MIB is a hierarchal (tree-like) structure that describes the "object Identifiers" (OID) for a given system. An OID is a variable and can be represented in a numerical form (representing its place in the hierarchy) or, sometimes, with a more descriptive textual name.
A MIB is a "namespace", it defines the meaning of an OID. There are MIBs per device category (eg. the Printer MIB) and there are vendor or device specific MIBs (eg. the Xerox MFC MIB, ...). Examples of OID-trees (MIBs) can be found at www.oidview.com, eg in http://www.oidview.com/mibs/0/Printer-MIB.html you can see that you might get a printer's toner level by reading the value of OID 188.8.131.52.184.108.40.206.1.1.9 (although you might need to first read OID 220.127.116.11.18.104.22.168.1.1.5 "prtMarkerSuppliesType" or 22.214.171.124.126.96.36.199.1.1.6 "prtMarkerSuppliesDescription " in order to get to the correct variable/value).
So, in order to "use" SNMP, you need
This gives us 2 scenarios of "Linux and SNMP" :
We'll mainly focus on scenario 1 : how to set up a linux system so it can be used to monitor SNMP-enabled devices, i.e. Linux as an SNMP 'manager'.
Install snmp client tools (snmpget, snmpwalk commands ...) :
apt-get install snmp
To be able to use OID text descriptions (in input and output of the snmp commands) rather than numeric OID's, you need to install MIBs. The more generic MIBs are available in the Debian and Ubuntu repos (debian: non-free, ubuntu: multiverse).
apt-get install snmp-mibs-downloader
the installer actually runs
/usr/bin/download-mibs which simply downloads published mibs from known web servers; you can repeat the process by executing it again. It has configuration files in
/etc/snmp-mibs-downloader and dumps the MIBs in
Additional, vendor-specific mibs can be "installed" by placing them in the MIBS directory :
You may need to (re)name the MIB to follow the convention (MIB_NAME).txt. (MIB_NAME) can be found on he first uncommented line of the MIB file (eg: Name-MIB DEFINITIONS ::= BEGIN).
You can test/use these commands by running snmpget or snmpwalk agains an snmp-enabled device:
snmpwalk -v1 -cpublic
Here's an example of a Nagios check by SNMP implemented as a shell script wrapper around snmpget