nagios通过SNMP服务的网络监控,当达到某个设定的值,那么就报警

http://bbotte.blog.51cto.com/6205307/1403997nagios服务端和客户端的安装配置

http://bbotte.blog.51cto.com/6205307/1583484Nagios结合pnp4nagios图形监控


借助于网上提供的资源,做下面的操作

https://github.com/cloved/check_traffic/releases 下载最新版本的shell脚本
下载check_traffic.sh V1.4.0,在附件已经上传

#被监控端/客户端

cd/usr/local/nagios/libexec/#下载此脚本chmod755check_traffic.sh#yuminstallnet-snmp-utilsnet-snmpnet-snmp-libsbc-y#因脚本里面需要用到bc#mv/etc/snmp/snmpd.conf/etc/snmp/snmpd.conf.bak#vim/etc/snmp/snmpd.conf#配置snmp服务#cat/etc/snmp/snmpd.conf|grep-v^\#|sed'/^$/d'com2secnotConfigUserdefaultpublicgroupnotConfigGroupv1notConfigUsergroupnotConfigGroupv2cnotConfigUserviewsystemviewincluded.1.3.6.1.2.1.1viewsystemviewincluded.1.3.6.1.2.1.25.1.1accessnotConfigGroup""anynoauthexactallnonenoneviewallincluded.180viewmib2included.iso.org.dod.internet.mgmt.mib-2fcaccessnotConfigGroup""anynoauthexactallnonenonesyslocationUnknown(edit/etc/snmp/snmpd.conf)syscontactRoot<root@localhost>(configure/etc/snmp/snmp.local.conf)dontLogTCPWrappersConnectsyes#servicesnmpdstart#snmpd-L#测试snmp配置文件Erroropeningspecifiedendpoint""ServerExitingwithcode1#./check_traffic.sh-V2c-Cpublic-Hlocalhost-L-vvvv#测试本机的网口,主要的数值是index后面的数字ListInterfaceforhostlocalhost.Interfaceindex1orrespondingtoloInterfaceindex2orrespondingtoeth0Interfaceindex3orrespondingtoeth2#./check_traffic.sh-V2c-Cpublic-H127.0.0.1-I2-w2000,3000-c3001,5000-K–BOK-Itisthefirsttimeofthispluginstorun,orsomedatafilelost.Wewillgetthedatafromthenexttime.#ll/var/tmp/check_traffic_127.0.0.1_2__itnms.hist_dat_64#检查权限,所属用户和组都为nagios#此脚本有帮助说明,用-h查看,上面-I2即是对eth0做监控,-w2000,3000是流入2000K/s,或发送3000K/s会提示warning#-V1|2c|3#Specifytheversionofsnmp##-CCommunity#SpecifytheCommunity##-Hhost#Specifythehost##-6Use64bitcounter,ifHC*insteadofif*.##-rUseRangeinsteadofsinglevalueinwarningandcriticalThreshold;##-Iinterface#Specifytheinterface##-Ninterfacename#Specifytheinterfacename##-LListallInterfacesonspecifyhost##-B/bSwitchtoB/sorbps,defaultis-b,bps##-K/MSwitchtoKorM(bsp,B/s),defaultis-K

#被监控端/客户端

vim/usr/local/nagios/etc/nrpe.cfgcommand[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh-V2c-Cpublic-H127.0.0.1-I2-w2000,4000-c4000,6000-K-B#servicenrpedrestart

#监控端/服务端

vim/usr/local/nagios/etc/objects/linuxhost.cfgdefinehost{usemylinux-server,service-pnphost_name192_168_23_2aliasservertongjiaddress192.168.23.2}vim/usr/local/nagios/etc/objects/linux13.cfgdefineservice{uselinux-service,service-pnphost_name192_168_1_2service_descriptionchecknetworkcheck_commandcheck_nrpe!check_traffic}

完事把nagios重启一下,刚开始会搜集数据,如下面的提示 大概2分钟就能看到图形界面了,

PNP4Nagios Version 0.6.24
Please check the documentation for information about the following error.
XML file "/usr/local/pnp4nagios/var/perfdata/192_168_1_2/check_network.xml" not found. <a href="http://docs.pnp4nagios.org/faq/6">Read FAQ online</a>

file [line]:
application/models/data.php [312]:
back

在nagios页面会看到



此图会有in,out的网卡流量,可以在服务器ifstat验证


此外,http://nagios.manubulon.com/ 这个网站也值得一看,里面有 http://nagios.manubulon.com/check_snmp_int.pl 脚本,同样可以实现对网络的监控

附件:http://down.51cto.com/data/2365405