nagios 监控 cisco 交换机

一、环境:
1.已搭建好nagios4.0.8
2.Centos6.5 x86_64

二、需要有4个监控cisco的脚本
check_snmp_cisco_ifstatus
check_snmp_cisco_loadavg
check_snmp_cisco_memutil
check_snmp_env
下载链接:http://down.51cto.com/data/2118262


三、配置
vim /usr/local/nagios/etc/objects/templates.cfg

definehost{nameetnet-switchusegeneric-hostcheck_period24x7check_interval1retry_interval1/2max_check_attempts2check_commandcheck-host-alivenotification_period24x7notification_interval30notification_optionsd,rcontact_groupsadminsregister0}


vim /usr/local/nagios/etc/objects/commands.cfg

##checkcisco#definecheck_snmp_envdefinecommand{command_namecheck_snmp_envcommand_line$USER1$/check_snmp_env-H$HOSTADDRESS$-C$ARG1$$ARG2$}#definecheck_snmpciscomemdefinecommand{command_namecheck_snmp_cisco_memcommand_line$USER1$/check_snmp_cisco_memutil-H$HOSTADDRESS$-C$ARG1$-w$ARG2$-c$ARG3$}#definecheck_snmpciscocpudefinecommand{command_namecheck_snmp_cisco_cpucommand_line$USER1$/check_snmp_cisco_loadavg-H$HOSTADDRESS$-C$ARG1$-w$ARG2$-c$ARG3$}#definecheck_snmpciscoifdefinecommand{command_namecheck_snmp_cisco_ifcommand_line$USER1$/check_snmp_cisco_ifstatus-H$HOSTADDRESS$-C$ARG1$-i$ARG2$-w$ARG3$-c$ARG4$}

vim /usr/local/nagios/etc/objects/151.3.cfg

definehost{useetnet-switchhost_nameOffice-192.168.151.3aliasSwitch151.3address192.168.151.3}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionPINGcheck_commandcheck_ping!200.0,20%!600.0,60%normal_check_interval5retry_check_interval1}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionUptimecheck_commandcheck_snmp!-Cpublic-osysUpTime.0}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionPort1LinkStatuscheck_commandcheck_snmp!-Cpublic-oifOperStatus.1-r1-mRFC1213-MIB}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionMemutilcheck_commandcheck_snmp_cisco_mem!public!90!95}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionLoadAVGcheck_commandcheck_snmp_cisco_cpu!public!90!95}defineservice{usegeneric-servicehost_nameOffice-192.168.151.3service_descriptionEnvironmentcheck_commandcheck_snmp_env!public}

添加监控交换机
vim /usr/local/nagios/etc/nagios.cfg

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



重启nagios
/etc/init.d/nagios restart

四、可能会报错

Nooutputonstdout)stderr:Can'tlocateNet/SNMP.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)at/usr/local/nagios/libexec/check_snmp_envline21.


问题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 .).

解决:

yuminstall-yperl-CPAN*



问题2:
No output on stdout) stderr: Can't locate Net/SNMP.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 .) at

/usr/local/nagios/libexec/check_snmp_env line 21.

解决:

perl-MCPAN-eshellcpan[1]>installNet::SNMPcpan[2]>quit

网上的解决方案
How do I install Net::SNMP perl module ? There are 2 ways of doing this
1) By CPAN (best)
on 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 will probably ask you some (simple) questions.
CPAN will also ask you to satisfy some dependencies (Crypt::DES, Digest::MD5, etc..).
2) "By hand"

Get the folowings modules (tar.gz format) on www.cpan.org
- Crypt::DES
- 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