This week I developed some plugins for Nagios/Icinga to monitor network devices of the vendor Extreme Networks. All these plugins receive status information of, eg. switches, via SNMP.
The Basic: Check Mem, CPU, and Fans
Checking for free memory, for CPU load, and for fan states is quite straight forward. You just ask the switch for the values of a few OIDs, evaluate the answer, and tell Nagios/Icinga what to do.
The Simple Network Management Protocol (SNMP) is actually a very easy to use protocol. There is an SNMP server, such as a router or a switch, which exposes management data through the SNMP protocol. To access these data you just send an object identify (OID) to an SNMP server and receive the corresponding value. So called management information bases (MIB) can tell you what a certain OID stands for.
On the command line, for example, you could use
snmpwalk to iterate over an OID subtree to, e.g., obtain information about the memory on a device:
usr@srv $ snmpwalk -v 2c -c publicCommunityString switch.address.com 220.127.116.11.4.1.1918.104.22.168.2.1 22.214.171.124.4.1.19126.96.36.199.188.8.131.52 = Gauge32: 1 184.108.40.206.4.1.19220.127.116.11.18.104.22.168 = STRING: "262144" 22.214.171.124.4.1.19126.96.36.199.188.8.131.52 = STRING: "116268" 184.108.40.206.4.1.19220.127.116.11.18.104.22.168 = STRING: "7504" 22.214.171.124.4.1.19126.96.36.199.188.8.131.52 = STRING: "138372"
184.108.40.206.4.1.19220.127.116.11.2.1 addresses the memory information table of the SNMP provider at
The value at
*.2.1 shows how much memory is installed,
*.3.1 shows how much memory is free,
*.4.1 shows how much is consumed by the system, and
*.5.1 shows how much is consumed by user processes. Basic calculations tell us there are
262144/1024 = 256KB in total and
100*116268/262144 = 44.35% is free.
A bit more logic for a warning/critical switch and the plugin is done.
The Feature: Monitoring of the FDB
But I would probably not write about that basic stuff if there was not an extra feature!