1.下载软件包
http://nagios.sourceforge.net/download/contrib/misc/check_traffic/check_traffic-0.90b.tar.gz
安装net-snmp-libs和net-snmp-utils
yum -y install net-snmp net-snmp-libs net-snmp-utils perl-rrdtool rrdtool
配置snmpd.conf
com2sec local localhost privatepass
group MyROGroup v1 local
group MyROGroup v2c local
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
access MyROGroup "" any noauth exact mib2 none none
service snmpd restart
上传check_traffic_nv.sh脚本到/fgn/theron/nagios/libexec/目录
chmod 755 ./check_traffic_nv.sh
测试脚本:
/fgn/theron/nagios/libexec/check_traffic_nv.sh -V 2c -C privatepass -H localhost -I 2 -w 12,30 -c 15,35 -M -b
chmod 777 /var/tmp/check_traffic_localhost_2.hist_dat
/fgn/theron/nagios/libexec/check_traffic_nv.sh -V 2c -H localhost -C privatepass -L
显示当前网口标识号:
List Interface for host localhost.
Interface index 1 orresponding to lo
Interface index 2 orresponding to eth0
Interface index 3 orresponding to sit0
nagios server端
新增command
vim commands.cfg
define command{
command_name check_traffic_nv
#./check_traffic_nv.sh [ -v ] [ -6 ] [ -r ] -V 1|2c|3 -C snmp-community -H host [ -L ] -I interface -w in,out-warning-value -c in,out-critical-value -K/M -B/b
command_line $USER1$/check_traffic.sh -V 2c -C privatepass -H localhost -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b
}
新增service
vim services.cfg
define service{
use local-service,srv-pnp ; Name of service template to use
host_name nagios
service_description check_nv_traffic_eth0
check_command check_traffic_nv!2!12,30!15,35
notifications_enabled 0
normal_check_interval 5 ;
retry_interval 1 ;
}
nagios client端
新增nrpe命令
vim nrpe.cfg
command[check_traffic_nv]=/fgn/theron/nagios/libexec/check_traffic_nv.sh -V 2c -C privatepass -H localhost -I 2 -w 12,30 -c 15,35 -M -b