nagios網卡流量監控 trffic.sh

來源:互聯網
上載者:User

標籤:nagios traffic 網卡流量監控

近兩天 在整合公司的監控  要不zabbix上 逐步遷移到 nagios+ganglia平台上

在網路監控這塊發現ganglia擷取的資訊不能自訂為Mb(也可能我沒有找對配置位置)

從網上 搜尋發現 有網友編寫了 traffic.sh的指令碼,我就拿來用了650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0057.gif" alt="j_0057.gif" />

traffic.sh  http://pan.baidu.com/s/1o8PoDBG

進入正題

用戶端  

1.安裝snmp組件

[[email protected] ~]# yum install -y  net-snmp   net-snmp-libs net-snmp-utils

2.更改設定檔 /etc/snmp/snmpd.conf

com2sec notConfigUser   default      public #改為 監控主機ip

access  notConfigGroup ""      any       noauth    exact  systemview  none none # 改為mib2

#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc # 去除注釋

3.測試連接 

snmpwalk -v 2c -c public 127.0.0.1 #需要將設定檔ip臨時改為127.0.0.1  正確的話會出現好多內容


服務端

1. 移動check_traffic.sh指令碼到 nagios外掛程式目錄,本例位於 /usr/lib64/nagios/plugins/

mv check_traffic.sh  /usr/lib64/nagios/plugins/

2.變更指令碼許可權 

chmod 755 check_traffic.sh

3.安裝 bc  #報錯資訊見error 1

[[email protected] plugins]# yum install -y bc.x86_64

4.

查看網卡編號

[[email protected] plugins]# /usr/lib64/nagios/plugins/check_traffic.sh -V 2c -C public -H 10.10.4.41 -L

測試 

/usr/lib64/nagios/plugins/check_traffic.sh -V 2c -C public -H 10.10.4.41 -I 2 -w 300,500 -c 600,800 -M -b           # -I 2的2為檢測到的網卡索引號

OK - The Traffic In is 33.38Mbps, Out is 15.28Mbps, Total is 48.66Mbps. The Check Interval is 90s |In=33.38Mbps;300;600;0;0 Out=15.28Mbps;500;800;0;0 Total=48.66Mbps;800;1400;0;0 Interval=90s;1200;1800;0;0

5.添加命令

vim /etc/nagios/objects/commands.cfg 

# ‘check_traffic‘ command definition

define command{

      command_name   check_traffic

      command_line   $USER1$/check_traffic.sh -V 2c -C public -H  $HOSTNAME$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -B

}

vim /etc/nagios/objects/api.cfg #本例是在現有的基礎上添加的 


define service{

        use                     api-service

         hostgroup_name              api

        service_description     check_traffic

        notifications_enabled   1

        check_command           check_traffic!2!300,300!600,600

        max_check_attempts      1

}



error 1

[[email protected] plugins]# /usr/lib64/nagios/plugins/check_traffic.sh -V 2c -C public -H 10.10.4.41 -I 2 -w300,500 -c600,800 -M -b

/usr/lib64/nagios/plugins/check_traffic.sh: line 449: bc: command not found

/usr/lib64/nagios/plugins/check_traffic.sh: line 454: bc: command not found

/usr/lib64/nagios/plugins/check_traffic.sh: line 457: bc: command not found

/usr/lib64/nagios/plugins/check_traffic.sh: line 458: bc: command not found

/usr/lib64/nagios/plugins/check_traffic.sh: line 461: [: too many arguments

/usr/lib64/nagios/plugins/check_traffic.sh: line 576: bc: command not found

/usr/lib64/nagios/plugins/check_traffic.sh: line 577: bc: command not found

解決方案

yum install -y bc 

error 2

Unknown - Can not found data in the history data file. Please to check the file /var/tmp/check_traffic_10.10.4.41_2.hist_dat_root__64 ,or use use verbose mode and check the debug file

 Unknown是由於

第一次執行,因為history data file不存在,因此會由此提示,可以忽略。

如果每次執行都忽略,則要檢查/var/tmp下是否有/var/tmp/check_traffic_${Host}_${Interface}.hist_dat檔案產生。


檔案的內容是系統當前的時間,in及out當前的數值。


在此感謝,兩位大神

http://blog.csdn.net/liansehai/article/details/15499767  戀澀海

http://bingdian.blog.51cto.com/94171/167614/  

本文出自 “明飛成長驛站” 部落格,謝絕轉載!

nagios網卡流量監控 trffic.sh

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.