2、上传监控插件至被监控机nagios/libexec目录并授权 | 具体实施:
安装:[iyunv@nagios nagios]# yum -y install net-snmp* # sec.name source community com2sec notConfigUser default public # sec.name source community com2sec notConfigUser 127.0.0.1(源IP) public(共同体名,即访问密码) access notConfigGroup "" any noauth exact systemview none none access notConfigGroup "" any noauth exact mib2 none none #view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc | 2、上传插件被授权,上传check_traffic.sh至/usr/local/nagios/libexec
cp /root/nagios/nagios-cn-3.2.3/sample-config/check_traffic.sh /usr/local/nagios/libexec/ chown nagios.nagios ./check_traffic.sh | 3、网卡参数检测:
检查启动情况
Netstat –na|grep 161
测试snmpwalk -v 1 -c public localhost system
Traffic 脚本测试,如果不知道网卡, 命令列出
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -L [iyunv@localhost snmp]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -L List Interface for host 127.0.0.1. Interface index 1 orresponding to lo Interface index 2 orresponding to eth0 Interface index 3 orresponding to sit0 [iyunv@localhost snmp]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 12,30 -c 15,35 -M -b OK - The Traffic In is 0.0Mbps, Out is 0.0Mbps, Total is 0.0Mbps. The Check Interval is 31s |In=0.0Mbps;12;15;0;0 Out=0.0Mbps;30;35;0;0 Total=0.0Mbps;42;50;0;0 Interval=31s;1200;1800;0;0 注:-V snmp协议版本 -C 共同体名 -I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。该插件其它使用方法及各参数解释详情”-help”或者看上面论坛石头描述 4.增加监控command
command_name check_traffic command_line $USER1$/check_traffic.sh -V 2c -C public -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b 5.nagios服务器配置添加监控项
############监控流量#################### use local-service,services-pnp ; Name of service template to use service_description check_traffic check_command check_traffic!2!12,30!15,35 |