標籤:交換器 伺服器 監控 local public
-
在交換器上啟用snmp並配置團體名(交換換機IP192.168.5.209)
Switch(config)#snmp-server community public ro
Switch(config)#snmp-server community public rw
2.在nagios伺服器上輸入如下命令擷取交換器的index資訊
[[email protected] ~]# /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的流量資訊
[[email protected] ~]# /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秒後再次輸入此命令
[[email protected] ~]# /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流量中已添加)
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/49/DB/wKiom1QcTvXQFzR5AACEj-rGH-U996.jpg" title="s1.png" alt="wKiom1QcTvXQFzR5AACEj-rGH-U996.jpg" />5.修改nagios.cfg,
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/49/DD/wKioL1QcT-awGOXrAAJR5s48qlc514.jpg" title="s2.png" alt="wKioL1QcT-awGOXrAAJR5s48qlc514.jpg" />
44 去掉 cfg_file=/usr/local/nagios/etc/objects/switch.cfg 的#號
6.修改switch.cfg,定義switch主機名稱和監控服務
[[email protected] ~]# vim /usr/local/nagios/etc/objects/switch.cfg
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/49/DB/wKiom1QcUdvjXhkBAAEn4vvXkq8238.jpg" title="s3.png" alt="wKiom1QcUdvjXhkBAAEn4vvXkq8238.jpg" />
25 使用generic-switch,此模板已存在templates.cfg中定義
26 主機名稱 使用了預設的 ,可以自訂
28 交換器的IP
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/49/DB/wKiom1QcUjzypW_8AAChysZE2SQ956.jpg" title="s4.png" alt="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進程
[[email protected] ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[[email protected] ~]# ps -ef | grep nagios
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/49/DB/wKiom1QcVW7wI7i-AAKbr7EIjMg652.jpg" title="s5.png" alt="wKiom1QcVW7wI7i-AAKbr7EIjMg652.jpg" />
[[email protected] ~]# kill 16416
[[email protected] ~]# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
8.訪問nagios監控頁面
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/49/DC/wKiom1QcVkKA2ZG_AAD70JysoaA241.jpg" title="s6.png" alt="wKiom1QcVkKA2ZG_AAD70JysoaA241.jpg" />
提示/var/tmp有個臨時檔案,把/var/tmp/ 下的臨時檔案全部刪除
[[email protected] ~]# cd /var/tmp/
[[email protected] tmp]# rm -f *
再殺掉進程,啟動進程,重新整理監控頁面
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/49/DD/wKioL1QcVzehYBOLAACbruUhEcU064.jpg" title="s7.png" alt="wKioL1QcVzehYBOLAACbruUhEcU064.jpg" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/49/DD/wKioL1QcV4GCLgEhAACSxAGyLkU941.jpg" title="s8.png" alt="wKioL1QcV4GCLgEhAACSxAGyLkU941.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
本文出自 “夢三國” 部落格,謝絕轉載!
nagios監控cisco交換器流量