Monitor Cisco switch ports with Nagios

EtherChannels on Cisco switches are great. You lose one link to the rest of the network you still have the other links in the etherchannel to fall back on. Unfortunately you won’t know you have lost any links until you have lost all the links in the etherchannel. A recipient for a bad day.

Luckly your switch will allow you to monitor interfaces using SNMP and what better monitoring software to use then Nagios.

The first step is to setup the SNMP on the switch. The two command you need in your switch are:

snmp-server community [community name] RO 1
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart

Here you setup snmp with a community name of your choosing that is read only and uses SNMP version 1. We also enable some traps but the one’s we are interested in are linkdown and linkup.

The MIB we will use for monitoring interfaces is the MIB-IF and it’s variable ifOperStatus.

Here is the config for the service in Nagios:

define service {
use                   generic-service
host_name            <hostname of switch>, <hostname of another switch>
service_description   Interface G1/0/1
check_comand          check_snmp!-C <community-name> -m IF-MIB -o ifOperStatus.10101

In my example I have defined a generic service with the description ‘Interface G1/0/1’ . I have added the hostname of all the switches I want to monitor port g1/0/1 of. The work is done by the check_snmp script, which creates a snmp connection using the community name specified earlier on the switch, the mib IF-MIB and the mib’s variable ‘ifOperStatus.101o1’. By changing the last numbers you change which interface you check. Some examples are:

g1/0/49 - 10149
g1/0/50 - 10150
g2/0/49 - 10649
g2/0/50 - 10650
g3/0/49 - 11149
g3/0/50 - 11150
Ten1/0/1 - 10201
Ten1/0/2 - 10202
Ten2/0/1 - 10701

Once the config file is done, all that is left todo is test the config and restart nagios.

Posted in Uncategorized | Leave a comment

Hello world!

Welcome to This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment