1.编写脚本
#!/bin/bash
#pid号定义
pid=6976
pid1=31202
pid2=29485
#执行循环
while :
do
ps -ef |grep lrsync |awk '{print $2}' | grep $pid &>/dev/null
if [ $? -ne 0 ];then
echo "1"
break
fi
ps -ef |grep lrsync |awk '{print $2}' | grep $pid1 &>/dev/null
if [ $? -ne 0 ];then
echo "1"
break
fi
ps -ef |grep lrsync |awk '{print $2}' | grep $pid2 &>/dev/null
if [ $? -ne 0 ];then
echo "1"
break
else
echo "0"
break
fi
done
给脚本添加权限
chmod 744 check_process.sh
2.写进zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=check_process,/bin/bash /root/check_process.sh
3.在zabbix服务器上查看返回值
zabbix_get -s 192.168.1.126 -k check_process
1
4.在zabbix网页上添加监控项
5.添加触发器
注意事项:
关于触发器的的表达式:
看下面连接
https://www.zabbix.com/documentation/3.4/zh/manual/config/triggers/expression