在系统运维中,对服务器的监控是必不可少的一个环节,今天就讲讲怎么通过nagios来监控服务器网卡的流量。
所需软件: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包 可以直接通过yum安装。
3.vi /etc/snmp/snmp.conf
a)更改 # sec.name source community
com2sec notConfigUser default public为
# sec.name source community
com2sec notConfigUser localhost 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
chkconfig --add snmpd
chkconfig snmpd on
检查启动情况
netstat –na|grep 161
如果不知道网卡可以使用如下命令列出
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -L
4.在/usr/local/nagios/etc/nrpe.cfg
加入command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C nagios -H localhost -I 2 -w 12,30 -c 15,35 -M –b
5.重启xinetd
可能遇到的问题:
1.报警service time out,出现该报警可能是由于没有启动snmpd服务导致。
2.nagios用户没有check_traffic_localhost_2__itnms.hist_dat_64的操作权限,ll查看该文件所属用户和组,确认为nagios或者nagios用户具有读写权限。
nagios监控网卡流量
原创
©著作权归作者所有:来自51CTO博客作者浅抒流年的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章