环境【centos系】

所需软件:net-snmp net-snmp-utils net-snmp-libs。

所需脚本:check_traffic.sh 见文章下方 附件
 
1.查看系统是否安装rpm -qa|grep snmp,如没有上传以上包,再上传check_traffic.sh脚本至$nagios/libexec/,并更改traffic脚本权限为 755
2.未安装时下载上面的snmp的rpm。
3.vi /etc/snmp/snmp.conf
a)更改
#       sec.name        source          community
com2sec notConfigUser   default         public
#       sec.name  source          community
com2sec notConfigUser  localhost(源IP)       nagios(访问密码)
b)更改
access  notConfigGroup ""      any       noauth    exact  systemview none none
access notConfigGroup "" any noauth exact mib2 none none
c)去掉该的#
#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
d)启动snmp
/etc/init.d/snmpd start
检查启动情况
Netstat –na|grep 161
测试snmp
#snmpwalk -v 1 -c nagios localhost system
Traffic 脚本测试
如果不知道网卡
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost –L命令列出
 
./check_traffic.sh -V 2c -C passwd -H localhost -I 2 -w 12,30 -c 15,35 -K -b