Nagios Monitoring Cisco Switches
First, the environment:
1. nagios4.0.8 has been built
2.centos6.5 x86_64
Second, 4 scripts are required to monitor Cisco
Check_snmp_cisco_ifstatus
Check_snmp_cisco_loadavg
Check_snmp_cisco_memutil
Check_snmp_env
Download Link: http://down.51cto.com/data/2118262
Third, the configuration
Vim/usr/local/nagios/etc/objects/templates.cfg
define host{ name etnet-switch use generic-host check_period 24x7 check_interval 1 retry_interval 1/2 max_check_attempts 2 check_command check-host-alive notification_period 24x7 notification_interval 30 notification_options d,r contact_groups admins register 0 }
Vim/usr/local/nagios/etc/objects/commands.cfg
# #check cisco#define check_snmp_envdefine command{command_name check_snmp_envcommand _line $USER 1$/check_snmp_env -h $HOSTADDRESS $ -c $ARG 1$ $ARG 2$} #define check_snmp cisco memdefine command{command_name check_snmp_cisco_memcommand_ line $USER 1$/check_snmp_cisco_memutil -h $HOSTADDRESS $ -c $ARG 1$ -w $ARG 2$ -c $ARG 3$} #define check_snmp cisco cpudefine command{command_name check_snmp_cisco_cpucommand_line $USER 1$/check_snmp_cisco_loadavg -h $HOSTADDRESS $ -c $ARG 1$ -w $ARG 2$ -c $ARG 3$} #define check_snmp cisco ifdefine command{command_name check_snmp_cisco_ifcommand_line $USER 1$/check_snmp_cisco_ifstatus -H $HOSTADDRESS $ -c $ARG 1$ -i $ARG 2$ -w $ARG 3$ -c $ARG 4$}
Vim/usr/local/nagios/etc/objects/151.3.cfg
define host{ use etnet-switch host_name Office-192.168.151.3 alias switch 151.3 address 192.168.151.3 }define service{ use generic-service host_name Office-192.168.151.3 service_description ping check_command check_ping!200.0,20%! 600.0,60% normal_check_interval 5 retry_check_interval 1 }define service{ use generic-service host_name Office-192.168.151.3 service_description Uptime check_command check_snmp!-c public -o sysuptime.0 }define service{ use generic-service host_name office-192.168.151.3 service_description port 1 Link Status check_command check_snmp!-c public -o ifoperstatus.1 -r 1 -m RFC1213-MIB }define service { use generic-service host_name office-192.168.151.3 service_ description memutil check_command check_snmp_cisco_mem!public!90! 95 }define service { use generic-service host_name Office-192.168.151.3 service_description loadavg check_command check_snmp_cisco_cpu!public!90!95 }define service { use generic-service host_name Office-192.168.151.3 Service_description environment check_command check_snmp_env! public }
Add Monitoring switch
Vim/usr/local/nagios/etc/nagios.cfg
Cfg_file=/usr/local/nagios/etc/objects/151.3.cfg
Restart Nagios
/etc/init.d/nagios restart
Four, may be error
No output on stdout) Stderr:can ' t locate net/snmp.pm in @INC (@INC contains:/usr/local/lib64/perl5/usr/local/share/perl 5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.) At/usr/local/nagios/libexec/check_snmp_env Line 21.
Question 1:
PERL-MCPAN-E Shell
Can ' t locate cpan.pm in @INC (@INC contains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.).
Solve:
Yum Install-y perl-cpan*
Question 2:
No output on stdout) Stderr:can ' t locate net/snmp.pm in @INC (@INC contains:/usr/local/lib64/perl5/usr/local/share/perl 5
/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.) At
/usr/local/nagios/libexec/check_snmp_env Line 21.
Solve:
PERL-MCPAN-E shellcpan[1]> Install net::snmpcpan[2]> quit
Solutions on the Web
How do I install Net::snmp perl module? There is 2 ways of doing this
1) by CPAN
command line, as root:
[your_host]# perl-mcpan-e Shell
CPAN Shell--cpan Exploration and modules installation (v1.76)
ReadLine Support Enabled
Cpan> Install NET::SNMP
If it ' s the first time you run CPAN, it'll probably ask you some (simple) questions.
CPAN'll also ask you to satisfy some dependencies (Crypt::D es, DIGEST::MD5, etc ...).
2) "By hand"
Get the Folowings modules (tar.gz format) on www.cpan.org
-Crypt::D es
-DIGEST::MD5
-DIGEST::SHA1
-Digest::hmac
-NET::SNMP
For each one (you must install NET::SNMP at the end):
Tar zxf <module>.tar.gz
CD <module>
Perl makefile.pl
Make Test
Make install
This article from "Small operations, Big dreams" blog, please be sure to keep this source http://hunkz.blog.51cto.com/6157447/1712572
Nagios Monitoring Cisco Switches