Monitoring Cisco Switch With Nagios Core Web Application

1. Overview

 

Nagios performance monitoring application can be used as an network monitoring tools to monitor various network device types such as switches, routers, firewalls as well as application performance monitoring on Linux and Windows servers for host up/down status, CPU usage, memory usage, switch or router interface up/down status , and more. It will send an alert when things go bad and when they get better.

In this instruction will show you how to monitor Cisco switch with Nagios performance monitoring application using some Nagios plugins that work base on SNMP protocol.

2. Prerequisites

 

In this article of monitoring Cisco switch with Nagios performance monitoring application, it is supposed that:

a. You have already done the initial server setup. Please refer to this link Minimal RHEL/CentOS 7 Initial Server Setup.
b. You have already installed Nagios performance monitoring application server. Please refer to this link. Installing Nagios Core For IT Infrastructure Monitoring on RHEL/CentOS 7

3. Configure SNMP on Device

 

First of all, we need to login to Cisco switch that we want to monitor it with Nagios performance monitoring application and configure SNMP server as the following. We will configure a read-only SNMP community string as “T@s9aMon” along with an ACL name “ACL-SNMP” to allow only a Nagios performance monitoring application server with IP address of 10.0.0.10 to be accessible to this device.

# ip access-list standard ACL-SNMP
     permit 10.0.0.10
# snmp-server community T@s9aMon RO ACL-SNMP
# snmp-server location DC
# snmp-server contact netadmin@techspacekh.com
# ip domain-name techspacekh.com

To test if the SNMP server on Cisco switch is configured properly and working, we need to login to Nagios performance monitoring application server and execute the following snmpwalk command. In the following command it is assumed that the IP address of Cisco switch is 10.0.0.1.

 

# snmpwalk -v2c -c T@s9aMon 10.0.0.1

4. Download And Test Nagios Plugin

 

To monitor a Cisco switch with Nagios performance monitoring application, we need two Nagios plugin. The first one is “check_cisco_switch.pl” and the second one is “check_cisco.pl”. You can download it from Nagios Exchange web site or you can download it directly here, check_cisco_switch and check_cisco. After download, you have to copy these two plugin into plugin directory on Nagios performance monitoring application server which is on “/usr/local/nagios/libexec“.

We will use a plugin name “check_cisco_switch.pl” to monitor power supply status, fan status, CPU usage, memory usage of a Cisco switch. This plugin is also possible to monitor interface up/down status of Cisco switch, but we will use another plugin name “check_cisco.pl” instead since it provides more comprehensive output such as interface description.

Now let go to directory to “/usr/local/nagios/libexec” to test these two plugin, but first we need to install the prerequisite packet to be able to execute this plugin and make it executable.

# cd /usr/local/nagios/libexec
# yum -y install perl-Net-SNMP
# chmod +x check_cisco_switch.pl

Now let use plugin name “check_cisco_switch.pl” to monitoring fan status of a Cisco switch.

 

# ./check_cisco_switch.pl -H 10.0.0.1 -C T@s9aMon -t fan
Fans: OK - 1 Fans are running all good | total=1 err=0

Now let use plugin name “check_cisco_switch.pl” to monitoring power supply status of a Cisco switch.

# ./check_cisco_switch.pl -H 10.100.1.22 -C T@s9aMon -t ps
PS: OK - 1 PS are running all good | total=1 err=0

Now let use plugin name “check_cisco_switch.pl” to monitoring CPU usage of a Cisco switch.

# ./check_cisco_switch.pl -H 10.0.0.1 -C T@s9aMon -t cpu -w 30 -c 70
Cpu: OK - Cpu Load 5% 5% 6% | cpu_5s=5percent;30;70 cpu_1m=5percent cpu_5m=6percent

Now let use plugin name “check_cisco_switch.pl” to monitoring memory usage of a Cisco switch.

# ./check_cisco_switch.pl -H 10.0.0.1-C T@s9aMon -t mem -w 50 -c 40
Memory: OK - Free Memory 83% | memory_total=90MB memory_used=15MB

We can also use this plugin to check interface status of a Cisco switch, but it is not provide a comprehensive out like the plugin name “check_cisco.pl” does.

#./check_cisco_switch.pl -H 10.0.0.1-C T@s9aMon -t int -i FastEthernet0/1
OK: FastEthernet0/1 -> up | int=1

Now, let test to use our second plugin “check_cisco.pl” to monitor the interface status of a Cisco switch since it could provide us a more comprehensive output, but we need  to install the prerequisite packet to be able to execute this plugin and make it executable.

# yum install -y net-snmp-utils
# chmod +x check_cisco.pl
# ./check_cisco.pl -H 10.100.1.22 -C A@B9aMon -i FastEthernet0/1
Fa0/1 up: ECC800-WAN1, LastChanges: (33570955) 3 days, 21:15:09.55, Traffic in : 27011460 octets, out: 143756229 octet

5. Define Host And Service Groups

 

It is better to create directories to store our own configuration files as the following.

# cd /usr/local/nagios
# mkdir techspacekh
# cd techspacekh/
# mkdir commands
# mkdir remotehosts
# mkdir servicegroups
# mkdir hostgroups

Then, we need to tell Nagios  performance monitoring application configuration file to also read the configuration files from the new directories we created and the restart Nagios performance monitoring application service.

# vim /usr/local/nagios/nagios.cfg
cfg_dir=/usr/local/nagios/etc/techspacekh
# systemctl restart nagios

Right now let create a host group name “cisco-switches” for all Cisco switch by going into directory “/usr/local/nagios/techspacekh/hostgroups” and create a file with cfg extension as the following.

# cd /usr/local/nagios/techspacekh/hostgroups
 # vim cisco-switches.cfg

define hostgroup{
  hostgroup_name cisco-switches
  alias Cisco Switches
  }

Then, let create some service groups for Cisco switch such as,memory-usage, cpu-usage, device-fan, device-powersupply, and cisco-interfacestatus by going into directory “/usr/local/nagios/techspacekh/hostgroups” and create a file with cfg extension as the following.

# cd /usr/local/nagios/techspacekh/servicegroups
# vim cisco-services.cfg

define servicegroup{
 servicegroup_name memory-usage
 alias Memory Usage
 }

define servicegroup{
 servicegroup_name cpu-usage
 alias CPU Usage
 }

define servicegroup{
 servicegroup_name device-fan
 alias Device Fan
 }

define servicegroup{
 servicegroup_name device-powersupply
 alias Device Power Suply
 }

define servicegroup{
 servicegroup_name cisco-interfacestatus
 alias Cisco Interface Status
 }

6. Define Nagios Commands

 

To use two plugins above, we need to define commands and call the plugin to use. Let define the following command to monitor power supply status, fan status, CPU usage, memory usage of a Cisco switch

# cd /usr/local/nagios/techspacekh/commands
# vim check_cisco_switch.cfg

define command{
 command_name check_cisco_switch
 command_line $USER1$/check_cisco_switch.pl -H $HOSTADDRESS$ -C $ARG1$ -t $ARG2$ -w $ARG3$ -c $ARG4$
 }

define command{
 command_name check_cisco_int
 command_line $USER1$/check_cisco.pl -H $HOSTADDRESS$ -C $ARG1$ -i $ARG2$
 }
#

7. Define Hosts And Services

 

After defining host group, service groups, and Nagios  performance monitoring application commands, right now we can define one host of Cisco switch to test. In this test switch we will monitor host down/up status, and some services such ping, CPU usage, memory usage, and the interface up/down status of two interfaces, F0/1 and F0/2.

# cd /usr/local/nagios/techspacekh/remotehosts
# vim test-switch01.cfg

define host{
 use generic-switch
 host_name Test-Switch01
 alias Test-Switch01
 notes Access Switch
 address 10.0.0.1
 hostgroups cisco-switches
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description PING
 check_command check_ping!200.0,20%!600.0,60%
 check_interval 5
 retry_interval 1
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description Memory Usage
 check_command check_cisco_switch!T@s9aMon!mem!50!40
 servicegroups memory-usage
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description CPU Usage
 check_command check_cisco_switch!T@s9aMon!cpu!60!70
 servicegroups cpu-usage
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description Device Fan
 check_command check_cisco_switch!T@s9aMon!fan
 servicegroups device-fan
 }
define service{
 use generic-service
 host_name Test-Switch01
 service_description Device Power Suply
 check_command check_cisco_switch!T@s9aMon!ps
 servicegroups device-powersupply
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description Port Fa0/1
 check_command check_cisco_int!T@s9aMon!Fa0/1
 servicegroups cisco-interfacestatus
 }

define service{
 use generic-service
 host_name Test-Switch01
 service_description Port Fa0/2
 check_command check_cisco_int!T@s9aMon!Fa0/2
 servicegroups cisco-interfacestatus
 }

After that, we need to restart Nagios performance monitoring application services with the following command.

# systemctl restart nagios

Go to the web interface of Nagios Core and we should see one host name “Test-Switch01” and some services as the following.

To see the host groups, from Nagios performance monitoring application web interface navigate to “Host Groups” tap and the following is the list of host groups.

To see the service groups, from Nagios performance monitoring application web interface navigate to “Service Groups” tap and the following is the list of service groups.

8. Conclusion

 

That’s all about how to monitoring Cisco switch with Nagios performance monitoring application from Tech Space KH. Nagios performance monitoring application is one of the best network monitoring tools  and server monitoring tools. Hopefully, you can find this guide informative. If you have any questions or suggestions you can always leave your comments below. I will try all of my best to review and reply them.

Comments

comments