客户端IP:192.168.1.11
服务端IP:192.168.1.12
目的:检查eip用户的java进程是否存在
客户端配置
脚本名:check_pid.sh
脚本如下:
#! /bin/bash
si=`ps -ef|grep java|grep eip|wc -l`
if [ $si -eq 1 ];then
echo "status ok"
exit 0
else
echo "The pro is down,plaese check!"
exit 1
fi
放在/home/monitor/nagios/libexec下,也就是nrpe插件存放的地方,chown -R monitor:monitor check_pid.sh
chmod +x check_pid.sh
cd /home/monitor/nagios/etc
vi nrpe.cfg
添加以下内容
command[check_pid.sh]=/home/monitor/nagios/libexec/check_pid.sh
重启nrpe
service xinetd restart
服务端配置:
同样的,在/home/monitor/nagios/libexec添加check_pid.sh
cd /home/monitor/nagios/etc
cd objects
vi commands.cfg
define command{
command_name check_pid.sh
command_line $USER1$/check_pid.sh $HOSTADDRESS$
}
cd /home/monitor/nagios/etc/services
vi 192.168.1.11.cfg
添加以下内容
define service{
use local-service
host_name 192.168.1.11
service_description check_pid.sh
check_command check_nrpe!check_pid.sh
}
重启nagios
service nagios restart
测试:
/home/monitor/nagios/libexec
./check_nrpe -H 192.168.1.11 -c check_pid.sh
看到返回信息
status ok
打开图形监控页面,可以看到
转载于:https://blog.51cto.com/axlewire/1604091