自定义监控进程

1.配置脚本取出想要的资源

[root@wyt3 ~]# mkdir /scripts
[root@wyt3 ~]# cd /scripts/
[root@wyt3 scripts]# vim check_process.sh
[root@wyt3 scripts]# cat check_process.sh
#!/ban/bash

process_status=$(ps -ef|grep $1|grep -Ev "grep|$0"|wc -l)
if [ $process_status -eq 0 ];then
    echo '1'
else
    echo '0'
fi
[root@wyt3 scripts]# chmod +x check_process.sh

2.在客户端启用自定义监控功能

[root@wyt3 ~]# vim /usr/local/etc/zabbix_agentd.conf 
//添加下面两行
UnsafeUserParameters=1
UserParameter=check_process[*],/bin/bash /scripts/check_process.sh $1

3.重启服务

[root@wyt3 ~]# pkill zabbix
[root@wyt3 ~]# zabbix_agentd 
[root@wyt3 ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128         *:22                      *:*                  
LISTEN     0      100    127.0.0.1:25                      *:*                  
LISTEN     0      128         *:10050                   *:*                  
LISTEN     0      128        :::22                     :::*                  
LISTEN     0      100       ::1:25                     :::*  

4.配置web界面添加监控项

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5.添加触发器

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

6.触发

[root@wyt3 ~]# systemctl stop postfix

7.收到告警邮件

在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lnsistw/article/details/107477717