Wednesday, 20 November 2013

Monitor Network Switch/Router in Nagios

---Add Network Switch---

1. Login as root user 
2. go /etc/nagios
3. Remove the leading pound (#) sign from the following line in the main configuration file:


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

# Definitions for monitoring a router/switch
cfg_file=/etc/nagios/objects/switch.cfg


4. go /etc/nagios/objects directory

define host{
use             generic-switch
host_name       core_switch_hatikumrul_172.22.83.1
alias           Cisco Core Switch Hatikumrul
address         172.22.83.1
}

# Service definition to ping the switch using check_ping
define service{
use                     generic-service
host_name       core_switch_hatikumrul_172.22.83.1
service_description     PING
check_command           check_ping!200.0,20%!600.0,60%
normal_check_interval   5
retry_check_interval    1
}

# Service definition to monitor switch uptime using check_snmp
define service{
use                     generic-service
host_name       core_switch_hatikumrul_172.22.83.1
service_description     Uptime
check_command           check_snmp!-C public -o sysUpTime.0
}

# Monitor ports 1 - 6 on the Cisco core switch.

define service{
use                   generic-service
host_name             core_switch_hatikumrul_172.22.83.1
service_description   Ports 1-6 Link Status
check_command         check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB, -o ifOperStatus.2 -r 1 -m RFC1213-MIB, -o ifOperStatus.3 -r 1 -m RFC1213-MIB, -o ifOperStatus.4 -r 1 -m RFC1213-MIB, -o ifOperStatus.5 -r 1 -m RFC1213-MIB, -o ifOperStatus.6 -r 1 -m RFC1213-MIB
}

define service{ 
use generic-service 
host_name localhost 
service_description Bandwidth Usage 
check_command check_local_mrtgtraf!/var/lib/mrtg/127.0.0.1_1.log!AVG!1000000,2000000!5000000,5000000!10 
 }


define service{
use        generic-service
host_name core_switch_hatikumrul_172.22.83.1
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/172.22.83.1_1.log!AVG!1000000,2000000!5000000,5000000!10
}

-----------mrtg---

[root@nagios archives]# rpm -qa | grep mrtg
mrtg-2.14.5-2
[root@nagios archives]# yum install mrtg







# 'check_local_mrtgtraf' command definition
define command{
        command_name    check_local_mrtgtraf
        command_line    $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
        }


# 'check_local_mrtgtraf' command definition 
define command{ 
command_name check_local_mrtgtraf 
command_line $USER1$/check_mrtgtraf -F $LOGFILE$ -a $ARG1$ -w $ARG3$,$ARG4$ -c $ARG5$,$ARG6$ 
 }

/usr/bin/nagios -v /etc/nagios/nagios.cfg



Restart nagios as shown below.
[nagios-server]# /etc/rc.d/init.d/nagios stop
Stopping nagios: .done.

[nagios-server]# /etc/rc.d/init.d/nagios start
Starting nagios: done.







No comments:

Post a Comment