nagios監控cisco交換機流量

  1. 在交換機上啓用snmp並配置團體名(交換換機IP192.168.5.209)

    Switch(config)#snmp-server community public ro

    Switch(config)#snmp-server community public rw

2.在nagios服務器上輸入如下命令獲取交換機的index信息

[root@localhost ~]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public  -H 192.168.5.209  -L

List Interface for host 192.168.5.209.

Interface index 1 orresponding to  Vlan1

Interface index 10001 orresponding to  FastEthernet0/1

Interface index 10002 orresponding to  FastEthernet0/2

Interface index 10003 orresponding to  FastEthernet0/3

Interface index 10004 orresponding to  FastEthernet0/4

Interface index 10005 orresponding to  FastEthernet0/5

Interface index 10006 orresponding to  FastEthernet0/6

Interface index 10007 orresponding to  FastEthernet0/7

Interface index 10008 orresponding to  FastEthernet0/8

Interface index 10009 orresponding to  FastEthernet0/9

Interface index 10010 orresponding to  FastEthernet0/10

Interface index 10011 orresponding to  FastEthernet0/11

Interface index 10012 orresponding to  FastEthernet0/12

Interface index 10013 orresponding to  FastEthernet0/13

Interface index 10014 orresponding to  FastEthernet0/14

Interface index 10015 orresponding to  FastEthernet0/15

Interface index 10016 orresponding to  FastEthernet0/16

Interface index 10017 orresponding to  FastEthernet0/17

Interface index 10018 orresponding to  FastEthernet0/18

Interface index 10019 orresponding to  FastEthernet0/19

Interface index 10020 orresponding to  FastEthernet0/20

Interface index 10021 orresponding to  FastEthernet0/21

Interface index 10022 orresponding to  FastEthernet0/22

Interface index 10023 orresponding to  FastEthernet0/23

Interface index 10024 orresponding to  FastEthernet0/24

Interface index 10101 orresponding to  GigabitEthernet0/1

Interface index 10102 orresponding to  GigabitEthernet0/2

Interface index 10501 orresponding to  Null0

3.在nagios服務器上輸入如下命令獲取交換機的F0/1的流量信息

[root@localhost ~]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 192.168.5.209 -I 10001 -w 200,300 -c 400,500 -K -B

OK - It's the first time for this plugins run. We'll get the data from the next time.

#第一次提示OK...,30秒後再次輸入此命令

[root@localhost ~]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 192.168.5.209 -I 10001 -w 200,300 -c 400,500 -K -B

OK - The Traffic In is 1.00KB, Out is 0.62KB, Total is 1.62KB. The Check Interval is 46s |In=1.00KB;200;400;0;0 Out=0.62KB;300;500;0;0 Total=1.62KB;500;900;0;0 Interval=46s;1200;1800;0;0

4.在commands.cfg 中添加check_traffic命令(在監控windows流量中已添加)

wKiom1QcTvXQFzR5AACEj-rGH-U996.jpg5.修改nagios.cfg, 

wKioL1QcT-awGOXrAAJR5s48qlc514.jpg

44 去掉 cfg_file=/usr/local/nagios/etc/objects/switch.cfg 的#號

6.修改switch.cfg,定義switch主機名和監控服務

[root@localhost ~]# vim /usr/local/nagios/etc/objects/switch.cfg

wKiom1QcUdvjXhkBAAEn4vvXkq8238.jpg

25 使用generic-switch,此模板已存在templates.cfg中定義

26 主機名 使用了默認的 ,可以自定義

28 交換機的IP


wKiom1QcUjzypW_8AAChysZE2SQ956.jpg

104 services-pnp,使用畫圖,裝有pnp纔有效果

105 要監控的主機名 links-srw224p,已在26行定義

106 服務描述    名稱自定義

107 檢查命令  check_traffic 已在commands.cfg中定義 10001 是交換機f0/1的index值 200 400 是

    進/出流量(單位KB)超過這個值會發出警告,500 800  是進/出流量超過這個值會發出報警(根據實際情況設置這些流量值)

7.測試修改內容是否有錯誤,並重啓nagios進程

[root@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

[root@localhost ~]# ps -ef | grep nagios

wKiom1QcVW7wI7i-AAKbr7EIjMg652.jpg

[root@localhost ~]# kill 16416

[root@localhost ~]# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

8.訪問nagios監控頁面

wKiom1QcVkKA2ZG_AAD70JysoaA241.jpg

提示/var/tmp有個臨時文件,把/var/tmp/  下的臨時文件全部刪除

[root@localhost ~]# cd /var/tmp/

[root@localhost tmp]# rm -f *

再殺掉進程,啓動進程,刷新監控頁面

wKioL1QcVzehYBOLAACbruUhEcU064.jpgwKioL1QcV4GCLgEhAACSxAGyLkU941.jpg

總結:這篇是根據前幾篇繼續做的

nagios服務搭建可參考http://nmszh.blog.51cto.com/4609205/1551295

snmpd.conf設置可參考http://nmszh.blog.51cto.com/4609205/1554465

services-pnp可參考http://nmszh.blog.51cto.com/4609205/1551644

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章