目 录CONTENT

文章目录

zabbix 自定义监控

ZiChen D
2021-10-11 / 0 评论 / 0 点赞 / 351 阅读 / 1,428 字 / 正在检测是否收录...

自定义进程监控

##编写脚本

[root@localhost ~]# mkdir /scripts
[root@localhost ~]# cd /scripts
[root@localhost ~]# vim check_process.sh
#!/bin/bash
  
count=$(ps -ef | grep -Ev "grep|$0" | grep -c "$1")
if [ $count -eq 0 ];then
    echo '1'
else
    echo '0'
fi

修改配置文件

[root@localhost etc]# pwd
/usr/local/etc
[root@localhost etc]# vim zabbix_agentd.conf

UnsafeUserParameters=1

# 配置文件末尾添加
UserParameter=check_process[*],/scripts/check_process.sh  $1

重启

[root@localhost ~]# pkill zabbix
[root@localhost ~]# zabbix_agentd 

Web界面配置

image.png

image.png

image.png

image.png

自定义日志监控

编写脚本

[root@localhost scripts]# ll
总用量 8
-rwxr-xr-x. 1 root root  124 10月  8 22:28 check_process.sh
-rwxr-xr-x. 1 root root 1854 10月  8 23:05 log.py
[root@localhost scripts]# pwd
/scripts

修改配置文件

[root@localhost etc]# vim zabbix_agentd.conf
//最后一行添加
UserParameter=check_log[*],/scripts/log.py  $1 $2 $3

//修改文件权限便于key访问
[root@localhost tmp]# chmod 755 /var/log/httpd

//在控制主机测试
[root@zabbix ~]# zabbix_get -s 192.168.164.133 -k check_log[/var/log/httpd/error_log]
0

0

评论区