Enable SNMP on the switch and configure the community name (Swap changer IP192.168.5.209)
Switch (config) #snmp-server Community public ro
Switch (config) #snmp-server Community public RW
2. Get the index information for the switch by entering the following command on the Nagios server
[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. Obtain the F0/1 traffic information for the switch by entering the following command on the Nagios server
[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 ..., enter this command again after 30 seconds
[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 are 1.00KB, out are 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. Add the check_traffic command in Commands.cfg (added in monitoring Windows traffic)
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. Modify 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 Remove the Cfg_file=/usr/local/nagios/etc/objects/switch.cfg #
6. Modify SWITCH.CFG, define switch hostname and monitor service
[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 using Generic-switch, this template already exists in templates.cfg defined
26 the hostname is used by default and can be customized
28 IP of the switch
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, using paint, with PnP only effect
105 Host name links-srw224p to monitor, defined in 26 rows
106 Service Description Name customization
107 Check command check_traffic already defined in Commands.cfg 10001 is the switch F0/1 's index value 200 400 is
The In/out flow (in kilobytes) exceeds this value to warn that 500 800 is the incoming/outbound traffic exceeding this value will alert (set these traffic values according to the actual situation)
7. Test the modification for errors and restart the Nagios process
[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. Visit the Nagios monitoring page
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/49/DC/wKiom1QcVkKA2ZG_AAD70JysoaA241.jpg "title=" s6.png "alt=" Wkiom1qcvkka2zg_aad70jysoaa241.jpg "/>
Tip/var/tmp have a temporary file, the temporary files under the/var/tmp/all deleted
[Email protected] ~]# cd/var/tmp/
[Email protected] tmp]# Rm-f *
Then kill the process, start the process, refresh the monitoring page
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 "/>
Summary: This article is based on the previous few to continue to do
Nagios Service setup can be referenced http://nmszh.blog.51cto.com/4609205/1551295
Snmpd.conf settings refer to http://nmszh.blog.51cto.com/4609205/1554465
SERVICES-PNP can refer to http://nmszh.blog.51cto.com/4609205/1551644
This article from "Dream Three" blog, declined reprint!
Nagios monitors Cisco switch traffic