使用nagios監控交換器連接埠流量,對低於閾值的流量進行警示

來源:互聯網
上載者:User

標籤:交換器   nagios   snmp   

需求:使用nagios服務需要對一台思科交換器的24連接埠進行流量監控,當流量低於2MB/s時,發送警示;當流量高於3MB/s時,警示取消;當流量介於2MB/s-3MB/s時,處於警告warning狀態。


操作方法:


第一:編寫指令檔:

vim /usr/lib64/nagios/plugins/check_traffic_less.sh

#!/bin/bashRXpre=$(/usr/bin/snmpwalk -v 2c -c public 10.10.3.242 IF-MIB::ifInOctets.10124 | awk ‘{print $4}‘)sleep 1RXnext=$(/usr/bin/snmpwalk -v 2c -c public 10.10.3.242 IF-MIB::ifInOctets.10124 | awk ‘{print $4}‘)RX=$((${RXnext}-${RXpre}))if [[ $RX -lt 2097152 ]];thenRX=$(echo $RX | awk ‘{print $1/1048576 "MB/s"}‘)   echo "critical,RX is $RX"   exit 2elif [[ $RX -gt 3145728 ]];thenRX=$(echo $RX | awk ‘{print $1/1048576 "MB/s"}‘)   echo "ok,RX is $RX"   exit 0elseRX=$(echo $RX | awk ‘{print $1/1048576 "MB/s"}‘)   echo "warning,RX is $RX"   exit 1fi

第二:添加許可權
chmod +x check_traffic_less.sh

第三:配置commands.cfg檔案
define command{
      command_name   check_traffic_less
      command_line   $USER1$/check_traffic_less.sh
}

第四:配置switch.cfg檔案
define service{
        use                     generic-service,srv-pnp ; Inherit values from a template
        host_name               H19_Unicom_Access_Switch_3.242
        service_description     check_traffice_less_g0/24
        check_command           check_traffic_less
        }

第五:重新載入服務::
service nagios reload

結果:

650) this.width=650;" title="image.png" src="https://s1.51cto.com/wyfs02/M01/9B/76/wKioL1ljWVCiuzcoAABckPTyQX8528.png" alt="wKioL1ljWVCiuzcoAABckPTyQX8528.png" />

本文出自 “榮耀屬於前輩” 部落格,請務必保留此出處http://lipenglong.blog.51cto.com/5309038/1946063

使用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.