nagios經過SNMP服務的網絡監控,當達到某個設定的值,那麼就報警php
http://bbotte.blog.51cto.com/6205307/1403997 nagios服務端和客戶端的安裝配置 linux
http://bbotte.blog.51cto.com/6205307/1583484 Nagios結合pnp4nagios圖形監控 ios
藉助於網上提供的資源,作下面的操做
git
https://github.com/cloved/check_traffic/releases 下載最新版本的shell腳本
下載check_traffic.sh V1.4.0,在附件已經上傳github
#被監控端/客戶端shell
cd /usr/local/nagios/libexec/ #下載此腳本 chmod 755 check_traffic.sh # yum install net-snmp-utils net-snmp net-snmp-libs bc -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' com2sec notConfigUser default public group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 access notConfigGroup "" any noauth exact all none none view all included .1 80 view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc access notConfigGroup "" any noauth exact all none none syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) dontLogTCPWrappersConnects yes # service snmpd start # snmpd -L #測試snmp配置文件 Error opening specified endpoint "" Server Exiting with code 1 # ./check_traffic.sh -V 2c -C public -H localhost -L -vvvv #測試本機的網口,主要的數值是index後面的數字 List Interface for host localhost. Interface index 1 orresponding to lo Interface index 2 orresponding to eth0 Interface index 3 orresponding to eth1 # ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,3000 -c 3001,5000 -K –B OK - It is the first time of this plugins to run, or some data file lost. We will get the data from the next time. # ll /var/tmp/check_traffic_127.0.0.1_2__itnms.hist_dat_64 #檢查權限,所屬用戶和組都爲nagios #此腳本有幫助說明,用-h查看,上面 -I 2 便是對eth0作監控,-w 2000,3000是流入2000K/s,或發送3000K/s會提示warning # -V 1|2c|3 # Specify the version of snmp # # -C Community # Specify the Community # # -H host # Specify the host # # -6 Use 64 bit counter, ifHC* instead of if*. # # -r Use Range instead of single value in warning and critical Threshold; # # -I interface # Specify the interface # # -N interface name # Specify the interface name # # -L List all Interfaces on specify host # # -B/b Switch to B/s or bps, default is -b, bps # # -K/M Switch to K or M (bsp,B/s), default is -K
#被監控端/客戶端
vim
vim /usr/local/nagios/etc/nrpe.cfg command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,4000 -c 4000,6000 -K -B # service nrped restart
#監控端/服務端
bash
vim /usr/local/nagios/etc/objects/linuxhost.cfg define host{ use mylinux-server,service-pnp host_name 192_168_23_2 alias server tongji address 192.168.23.2 } vim /usr/local/nagios/etc/objects/linux13.cfg define service{ use linux-service,service-pnp host_name 192_168_1_2 service_description check network check_command check_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 腳本,一樣能夠實現對網絡的監控