原文地址:
http://blog.sina.com.cn/s/blog_6eee53080100yed4.html
插件下载地址 :
http://www.rayfile.com/files/4d6f1bb0-e591-11e0-9847-0015c55db73d/
如果失效,这个插件太不好找和下载了。可以邮件找我要59866276@qq.com
一:主要步骤
1,安装snmpd服务包,并且设置好团体名称,添加系统启动
2,部署check_traffic.sh到nagios的插件目录到libexec并且授权哦。
3,网卡检测参数。
4,nagios设置command.cfg的command,添加service.cfg文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
二:具体干活细节
1,安装snmpd,修改内容,设置开机启动
安装snmpd
yum install net-snmp*
修改snmpd.conf
vim snmpd.conf内容如下:(注意修改加粗部分内容)
com2sec notConfigUser ip 团体名称
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
设置系统启动文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
chkconfig --add snmpd文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
chkconfig snmpd on文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
2,部署check_traffic.sh文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
上传到nagios的安装目录libexec,并且授权755,属性为nagios的用户和组文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
chmod 755 check_traffic.sh文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
chown nagios.nagios check_traffic.sh文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
3、网卡参数检测文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
[root@10.60.30.53 /usr/local/nagios/libexec]$ ./check_traffic.sh -V 2c -C 团体名称 -H 10.60.30.52 -L
List Interface for host 10.60.30.52.
RFC1213-MIB::ifDescr.1 orresponding to "lo"
RFC1213-MIB::ifDescr.2 orresponding to "eth0"
RFC1213-MIB::ifDescr.3 orresponding to "eth1"
RFC1213-MIB::ifDescr.4 orresponding to "eth2"
RFC1213-MIB::ifDescr.5 orresponding to "eth3"
RFC1213-MIB::ifDescr.6 orresponding to "sit0"
[root@10.60.30.53 /usr/local/nagios/libexec]$文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
可以测试是否能够正常采集到数据(如果取不到,检查snmpd的团体名称、被监控者的IP,还有selinux是否关闭)文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
[root@10.60.30.53 /usr/local/nagios/libexec]$ ./check_traffic.sh -V 2c -C 团体名称 -H 10.60.30.52 -I 2 -w 1200,1500 -c 1700,1800 -K -B
OK - The Traffic In is 0.37KB, Out is 0.75KB, Total is 1.12KB. The Check Interval is 1129s |In=0.37KB;1200;1700;0;0 Out=0.75KB;1500;1800;0;0 Total=1.12KB;2700;3500;0;0 Interval=1129s;1200;1800;0;0
[root@10.60.30.53 /usr/local/nagios/libexec]$文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
解释:文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
-V snmp协议版本文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
-C 共同体名文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
-I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
-w 警告值 -c报警值文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
4,nagios的配置文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
增加nagios的command.cfg文章源自运维生存时间-https://www.ttlsa.com/nagios/check_traffic-sh-monitor-traffic/
# 'check_traffic' command definition
define command{
command_name check_traffic
command_line $USER1$/check_traffic.sh -V 2c -C 团体名称 -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -K -B
}
解释:-I 第几个网卡 -K –B设置的报警参数数值是KB,不是MB
增加service.cfg
define service{
use generic-service ; Name of service template to use
host_name db_31
service_description check_eth0_traffic
check_command check_traffic!2!4000,5000!6000,7000;该处设置的是kB,不是MB
}
图8-1
评论