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
#客户端没有安装mysql服务,所以显示为1

本文介绍了如何在ZABBIX中自定义监控Linux系统的进程和服务状态,通过配置监控脚本、添加监控项和触发器,实现了当httpd服务关闭时触发报警。同时,文章详细讲解了自定义监控日志的过程,包括服务端和客户端的操作,以及如何编写和测试日志监控脚本。
最低0.47元/天 解锁文章
778

被折叠的 条评论
为什么被折叠?



