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
com2secnotConfigUser localhost nagios (原为com2secnotConfigUser default public)
access notConfigGroup "" any noauth exacthmib2 none none (原为access notConfigGroup "" any noauth exacthsystemview 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=/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
页:
[1]