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服务器上查看返回值