ZABBIX自定义监控进程和日志
配置监控脚本
客户端
[root@localhost ~]# dnf -y install httpd
[root@localhost ~]# systemctl start httpd
创建脚本存放目录,并编辑脚本
[root@localhost ~]# mkdir /etc/scripts
[root@localhost ~]# cd /etc/scripts/
[root@localhost scripts]# vim check_process.sh
#!/bin/bash
count=$(ps -ef |grep -Ev "grep|$0"|grep $1|wc -l)
if [ $count -eq 0 ];then
echo 0
else
echo 1
fi
[root@localhost scripts]# chmod +x check_process.sh
配置zabbix_agentd文件
[root@localhost ~]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d
[root@localhost etc]# vim zabbix_agentd.conf
...
UnsafeUserParameters=1
UserParameter=check_process[*],/bin/bash /etc/scripts/check_process.sh $1 //添加至最后
#更改配置文件后重启zabbix服务
[root@localhost etc]# pkill zabbix
[root@localhost etc]# zabbix_agentd
服务端
检测一下check_process能否使用
[root@localhost ~]# zabbix_get -s 192.168.48.151 -k check_process[httpd]
0
#客户端httpd服务正常运行中,所以显示为0
[root@localhost ~]# zabbix_get -s 192.168.48.151 -k check_process[mysql]
1
#客户端没有安装