- 参考文档
- 无
- 步骤
- 1.客户端获取数据
- [root@niaoyun-101 ~]# cd /usr/lib64/nagios/shell
- [root@niaoyun-101 shell]#vi check_traffic.sh
- [root@niaoyun-101 shell]# cat check_traffic.sh
- #!/bin/bash
- warn=$1
- critical=$2
- REV=`sar -n DEV 1 1 | grep eth0 | grep Average: | awk '{print $5}' | awk -F '.' '{print $1}'`
- SED=`sar -n DEV 1 1 | grep eth0 | grep Average: | awk '{print $6}' | awk -F '.' '{print $1}'`
- if [[ $REV -lt $warn && $SED -lt $warn ]]
- then
- echo "traffic OK < ${warn}kb [input:$REV ,output:$SED ]"
- exit 0
- else
- echo "traffic WARN ≥ ${warn}kb [input:$REV ,output:$SED ]"
- exit 1
- fi
- [root@niaoyun-101 shell]# chmod 755 check_traffic.sh
- 2.客户端nrpe.cfg 修改参数
- command[check_traffic]=/usr/lib64/nagios/shell/check_traffic.sh 1000
- 3.客户端重启nrpe服务
- [root@niaoyun-101 nagios]# /etc/init.d/nrpe restart
- 4.服务端测试是否有数据返回:
- [root@niaoyun-6 conf.d]# /usr/lib64/nagios/plugins/check_nrpe -H 118.192.147.101 -c check_traffic
- traffic OK < 1000kb [input:0 ,output:0 ]
- [root@niaoyun-6 conf.d]#
- 5.服务端修改对应主机的cfg文件 增加对应监控项
- define service {
- use generic-service
- host_name 118.192.147.101
- service_description check_traffic
- check_command check_nrpe!check_traffic
- max_check_attempts 5
- notifications_enabled 1
- }
- 6.服务端重启nagios
- [root@niaoyun-6 conf.d]# nagios -v /etc/nagios/nagios.cfg
- [root@niaoyun-6 conf.d]# /etc/init.d/nagios restart
- 最新活动: 2016-05-06 09:27
- 浏览: 1235
- 关注: 0 人
编辑回复