1、安裝所需組件
成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括敦化網(wǎng)站建設(shè)、敦化網(wǎng)站制作、敦化網(wǎng)頁(yè)制作以及敦化網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,敦化網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到敦化省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
yum install perl perl-devel perl-CPAN bc net-snmpd net-snmp-utils -y
perl -MCPAN -eshell & cpan> install Bundle::LWP
編譯安裝nrpe(參考教程:http://2860664.blog.51cto.com/2850664/1559056)
以下是被監(jiān)控端設(shè)置
2、下載check_traffic.s腳本
下載地址:https://codeload.github.com/cloved/check_traffic/zip/v1.3.11
解壓文件后,上傳check_traffic.sh到/usr/local/nagios/libexec
chmod +x check_traffic.sh
chown nagios.nagcmd check_traffic.sh
3、設(shè)置snmp參數(shù)
vi /etc/snmp/snmpd.conf
com2sec notConfigUser 被監(jiān)控端IP 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 syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
service snmpd start
chkconfig snmpd on
4、在被監(jiān)控端測(cè)試腳本
cd /usr/local/nagios/libexec
./check_traffic.sh -V 2c -C public -H 192.168.1.247 -I 2 -w 1200,1500 -c 1700,1800 -K -B
OK - The Traffic In is 0.72KB, Out is 0.60KB, Total is 1.32KB. The Check Interval is 43s |In=0.72KB;1200;1700;0;0 Out=0.60KB;1500;1800;0;0 Total=1.32KB;2700;3500;0;0 Interval=43s;1200;1800;0;0
其中紅色為被監(jiān)控端的IP地址。
4、vi /usr/local/nagios/etc/nrpe.cfg 添加
command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 192.168.1.247 -I 2 -w 1200,1500 -c 1700,1800 -K -B
以下是nagios主機(jī)的設(shè)置
5、服務(wù)器端測(cè)試
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.247 -c check_traffic
OK - The Traffic In is 0.48KB, Out is 0.11KB, Total is 0.59KB. The Check Interval is 28s |In=0.48KB;1200;1700;0;0 Out=0.11KB;1500;1800;0;0 Total=0.59KB;2700;3500;0;0 Interval=28s;1200;1800;0;0
vi /usr/local/nagios/etc/nagios.cfg 添加
cfg_file=/usr/local/nagios/etc/objects/nginx.cfg
6、touch /usr/local/nagios/etc/objects/nginx.cfg
vi /usr/local/nagios/etc/objects/nginx.cfg (注意修改被監(jiān)控端的IP)內(nèi)容如下
****************************************我是分割線************************************
define host{ use linux-server host_name nginx alias nginx address 被監(jiān)控端IP } define service{ use generic-service host_name nginx service_description check-swap check_command check_nrpe!check_swap } define service{ use generic-service host_name nginx service_description check-load check_command check_nrpe!check_load } define service{ use generic-service host_name nginx service_description check-disk check_command check_nrpe!check_sda1 } define service{ use generic-service host_name nginx service_description check-users check_command check_nrpe!check_users } define service{ use generic-service host_name nginx service_description otal_procs check_command check_nrpe!check_total_procs } define service{ use generic-service ; Name of service template to use host_name nginx service_description PING check_command check_ping!100.0,20%!500.0,60% } define service{ use generic-service host_name nginx service_description nginx_status check_command check_nrpe!check_nginx! notifications_enabled 0 } define service{ use generic-service host_name nginx service_description network_traffic check_command check_nrpe!check_traffic! notifications_enabled 0 }
****************************************我也是分割線************************************
報(bào)錯(cuò)信息
7、nagios服務(wù)器報(bào)錯(cuò)
Unknown - Read or Write File /var/tmp/check_traffic_192.168.1.247_2__itnms.hist_dat_64 Error with user uid=501(nagios) gid=503(nagcmd) groups=502(nagios),503(nagcmd).
解決方法:chmod nagios.nagcmd /var/tmp/check_traffic_192.168.1.247_2__itnms.hist_dat_64
文章名稱:nagios監(jiān)控linux網(wǎng)卡流量(check_traffic.sh)
文章分享:http://sd-ha.com/article18/ihhggp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、做網(wǎng)站、網(wǎng)站維護(hù)、Google、響應(yīng)式網(wǎng)站、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)