How to monitor san switches using snmp with Nagios or Icinga

Overview

Monitoring of network devices like switches, routers and hardware firewalls can be performed easily using monitoring tools like Nagios or Icinga. The prerequisites require basic knowledge of snmp protocol and an existing setup of Nagios or Icinga. This post assumes that you already have Icinga or Nagios installed and running. If not then follow these posts to install Icinga or Nagios

Also I assume that snmp is enabled and working on san switches, get in touch with your storage administrator and ask him to enable snmp v3 on the switches. Every major managed switch can be setup to send snmp information. The storage administrator would probably provide you ip address of the switch and some other parameters like auth type, authuser, authpassword. The only other thing that is required now is the OID’s of all the parameters that we would be monitoring. To find the OID’s we would be using a tool called MIB Browser. Lets start then.

How to monitor san switches using snmp with Nagios or Icinga

First and foremost we would like nagios to start reading switch config file.


# vi /usr/local/nagios/etc/nagios.cfg

Uncomment line 45 for nagios to start reading the switch.cfg file


cfg_file=/usr/local/nagios/etc/objects/switch.cfg

Open switch.cfg in an editor of choice and define our switch


# vi /usr/local/nagios/etc/objects/switch.cfg

Append the following definition, replace the address with the ip address of your switch.


define host{
        use             generic-switch          
        host_name       San-Switch01      
        alias           Cisco SanSwitch   
        address         192.168.209.1           
        hostgroups      switches                
        }

The things that we would want to monitor are the fiber channel ports. To monitor these we need to know the OIDs, we will use a tool know as MIB Browser. It is a paid tool but you can download 30 days evaluation version here. Install it and find the OIDs.

sanswitch01 How to monitor san switches using snmp with Nagios or Icinga

sanswitch02 How to monitor san switches using snmp with Nagios or Icinga

sanswitch03 How to monitor san switches using snmp with Nagios or Icinga

The next thing we would be doing is compiling check_multi plugin. To find out what check_multi is and how to compile it click here.

Once check_multi plugin is installed, create a new command file for check_multi.


# vi /usr/local/nagios/etc/objects/switches/sanswitch.cmd

Append the following to the file. You need to define the commands for all the ports need to be monitored. Let me explain one command here.

command[fc1-2]=/usr/lib/nagios/plugins/check_snmp -P 3 -U admin -L authNoPriv -a MD5 -A abc@123 -H 192.168.209.1 -o ifOperStatus.16781312 -c 1

The command is to monitor fiber channel port 2 of enclosure 1. It is using check_snmp plugin, -H is followed by the ip address of the switch, -P followed by the version of snmp being used, -U followed by the auth username, -L followed by the security level, -a followed by auth protocol, -A followed by the authpasswd, -o followed by the OID we extracted using MIB Browser, -c 1 means to make it critical if the output is other than 1 since 1 is for OK any-other value should alert us. Please change the authusename, password, host ip and other parameters according to your environment.

Sample commands for my switch.


command[fc1-2]=/usr/lib/nagios/plugins/check_snmp -P 3 -U admin -L authNoPriv -a MD5 -A abc@123 -H 192.168.209.1 -o ifOperStatus.16781312 -c 1
command[fc-mgmt0]=/usr/lib/nagios/plugins/check_snmp -P 3 -U admin -L authNoPriv -a MD5 -A abc@123 -H 192.168.209.1 -o ifOperStatus.83886080 -c 1
command[fc-sup-fc0]=/usr/lib/nagios/plugins/check_snmp -P 3 -U admin -L authNoPriv -a MD5 -A abc@123 -H 192.168.209.1 -o ifOperStatus.101191680 -c 1

Next open the commands configuration file in an editor


# vi /usr/local/nagios/etc/objects/commands.cfg

Define a command to be used for check_multi


define command{
command_name check_multi_snmp
command_line /usr/local/nagios/libexec/check_multi -f $ARG1$ -r $ARG2$ -T 180
}

Open switch.cfg in an editor of choice


# vi /usr/local/nagios/etc/objects/switch.cfg

Finally define the service


define service{
use generic-service
host_name San-Switch01
service_description SwitchPorts
check_command check_multi_snmp!/usr/local/nagios/etc/objects/switches/sanswitch.cmd!15
}

sanswitch011 300x176 How to monitor san switches using snmp with Nagios or Icinga