nagios監控網路流量

來源:互聯網
上載者:User

標籤:nagios 流量監控 check_traffic

系統版本

[[email protected] libexec]# cat /etc/redhat-release 

CentOS release 5.6 (Final)


1 安裝和配置snmp

1)yum install net-snmp-utils net-snmp net-snmp-libs -y

2)vi /etc/snmp/snmpd.conf

把下面兩行的#號去掉

#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc

#view all included .1           80

把下面的語句

access notConfigGroup "" any noauth exact systemview none none

改為:

access notConfigGroup "" any noauth exact mib2 none none

3) 啟動snmp

/etc/init.d/snmpd  start

2 下載監控流量指令碼測試

wget https://raw.githubusercontent.com/cloved/check_traffic/master/check_traffic.sh --no-check-certificate   ##放到/usr/local/nagios/libexec目錄下

chmod +x /usr/local/nagios/libexec/check_traffic.sh

擷取網卡資訊

[[email protected] libexec]#  ./check_traffic.sh -V 2c -C public -H localhost -L

List Interface for host localhost.

Interface index 1 orresponding to  lo

Interface index 2 orresponding to  eth0   

[[email protected] libexec]#  ./check_traffic.sh -V 2c -C public -H localhost -I 2  -w 1000,1200 -c 1400,1500 -K -B    ## -I 後面的2 由上面的命令擷取

OK - The Traffic In is 0.11KB, Out is 1.08KB, Total is 1.19KB. The Check Interval is 1526s |In=0.11KB;1000;1400;0;0 Out=1.08KB;1200;1500;0;0 Total=1.19KB;2200;2900;0;0 Interval=1526s;1200;1800;0;0

定義in和out值分別超過1000K、1200K警告,超過1400K,1500k嚴重。(第一次運行沒有輸出,30s後再運行就有輸出)

3 在被監控端定義check_traffic命令

 vi /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 1000,1200 -c 1400,1500 -K -B 

4 在監控端定義服務

vi ../etc/objects/services.cfg   

添加

define service{

        use                          generic-service

        host_name               localhost

        service_description          traffic

        check_command                check_nrpe!check_traffic

              }

5 重啟服務

pkill nrpe 

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

/etc/init.d/nagios reload

6 手動測試

[[email protected] libexec]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_traffic

OK - The Traffic In is 0.0KB, Out is 0.24KB, Total is 0.24KB. The Check Interval is 135s |In=0.0KB;200;400;0;0 Out=0.24KB;300;500;0;0 Total=0.24KB;500;900;0;0 Interval=135s;1200;1800;0;0

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />


nagios監控網路流量

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.