Zabbix自定义监控

一、自定义监控进程

写脚本,脚本放在统一位置

修改被监控机zabbix_agentd.conf配置文件

UnxsafeParameters=1
UnserParameter=<key>,<command>

重启zabbix_agent

在web界面配置监控项和触发器

监控httpd

// 在客户端安装httpd
[root@centos ~]# yum -y install httpd
[root@centos ~]# systemctl start httpd
[root@centos ~]# ss -antl
State  Recv-Q  Send-Q   Local Address:Port    Peer Address:Port Process                                                         
LISTEN 0       128            0.0.0.0:22           0.0.0.0:*                                                                    
LISTEN 0       128            0.0.0.0:10050        0.0.0.0:*                                                                    
LISTEN 0       128                  *:80                 *:*                                                                    
LISTEN 0       128               [::]:22              [::]:*    

// 监控httpd进程
[root@centos ~]# ps -ef | grep httpd
root       36614       1  0 22:29 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     37392   36614  0 22:29 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     37393   36614  0 22:29 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     37395   36614  0 22:29 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     37396   36614  0 22:29 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
root       38613    1473  0 22:30 pts/0    00:00:00 grep --color=auto httpd

修改客户端zabbix_agentd文件zabbix_agentd.conf

[root@centos ~]# cd /usr/local/etc/
[root@centos etc]# ls
zabbix_agentd.conf  zabbix_agentd.conf.d
[root@centos etc]# vim zabbix_agentd.conf

# Default:
UnsafeUserParameters=1
UserParameter=check_process[*],/scripts/check_process.sh $1

// 修改完配置文件重启服务
[root@centos ~]# pkill zabbix
[root@centos ~]# zabbix_agentd

编写进程然后进行测试

// 创建并进入脚本目录
[root@centos ~]# mkdir /scripts
[root@centos ~]# cd /scripts/

// 编写一个脚本
[root@centos scripts]# vim check_process.sh
#!/bin/bash

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

返回服务端查看配置文件是否存在问题

[root@localhost ~]# zabbix_get -s 192.168.91.135 -k check_process[httpd]
0

[root@centos ~]# systemctl stop httpd.service

[root@localhost ~]# zabbix_get -s 192.168.91.135 -k check_process[httpd]
1

在zabbix网页上添加监控项
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
添加触发器
在这里插入图片描述
选择报警程度,填写名字,add添加
在这里插入图片描述
在这里插入图片描述

二、自定义监控日志

写脚本,脚本放在统一位置

修改被监控机zabbix_agentd.conf配置文件

UnxsafeParameters=1
UnserParameter=<key>,<command>

重启zab

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值