nagios 监控流量(借助脚本)


nagios 监控流量(借助脚本)


http://www.sunchis.com/uploads/soft/364_check_traffic_v1.2.2.zip

 

# mount /dev/cdrom /media/cdrom

# rpm - ivh  /media/cdrom/Server/lm_sensors-2.10.0-3.1.i386.rpm

# rpm - ivh  /media/cdrom/Server/net-snmp-5.3.1-14.e15.i386.rpm

# rpm -ivh /media/cdrom/Server/net-snmp-utils-5.3.1-14.e15.i386.rpm

# vi /etc/snmp/snmp.conf

com2sec  notConfigUser     localhost     nagios     (原为com2sec  notConfigUser     default     public)

access   notConfigGroup "" any noauth exacth  mib2 none none    (原为access   notConfigGroup "" any noauth exacth  systemview none none)

view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc     (去掉注释符“#”即可)

:wq

# service snmpd start

# chkconfig --add snmpd

# chkconfig --level 35 snmpd on


# unzip 364_check_traffic_v1.2.2.zip

# cp check_traffic.sh  /usr/local/nagios/libexec

# chmod +x /usr/local/nagios/libexec/check_traffic.sh

# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -L   (查看所有网卡)

# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M -b (查看网卡结果中的第2个即eth0,进的流量限制为12-30m,出的流量限制为15-35m,即12为警告值,30为报警指)

# visudo

nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_traffic.sh

:wq


# vi /usr/local/nagios/etc/nrpe.cfg
 
command[check_traffic]=/usr/bin/sudo /usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M -b
 
:wq
 

# killall nrpe
 
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
 
# vi /usr/local/nagios/etc/objects/ming.cfg

define service{
          use              generic-service
          host_name        ming
          service_description traffic
          check_command      check_nrpe!check_traffic
          normal_check_interval    2
}
 
:wq
 
 
# service nagios restart

本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/857687如需转载请自行联系原作者


yangzhimingg

上一篇:监控网卡流量


下一篇:从零开始搭建Java开发环境第三篇:最新版IDEA常用配置指南,打造你的最酷IDE