zabbix自定义监控

1.进程监控

在web客服端编写脚本 取出需要监控资源的状态值

//创建目录
[root@web ~]# mkdir /scripts
 
//编写内容脚本
[root@web ~]# vim /scripts/check_process.sh
[root@web ~]# cat /scripts/check_process.sh 
#!/bin/bash
status=$(ps -ef |grep $1|grep -Ev "$0|grep"|wc -l)
if [ $status -eq 0 ];then
            echo '1'
    else
                echo '0'
        fi
 
//给执行权限
[root@web ~]# chmod +x /scripts/check_process.sh 
 
//查看
[root@web ~]# ll /scripts/check_process.sh 
-rwxr-xr-x 1 root root 129 Sep  7 01:04 /scripts/check_process.sh
[root@web ~]#

1.1在agent客服端编写配置文件

//将下面两行取消注释作修改,或者直接添加这两行
[root@localhost ~]# vim /usr/local/etc/zabbix_agentd.conf
# Mandatory: no
# Range: 0-1
# Default:
UnsafeUserParameters=1    //取消注释 改为1
 
### Option: UserParameter
#       User-defined parameter to monitor. There can be several user-defined parameters.
#       Format: UserParameter=<key>,<shell command>
#       See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
 UserParameter=check_process[*],/bin/bash /scripts/check_process.sh $1  //取消注释写入内容
 
//重启agent,生效作更改的配置
[root@web ~]# pkill zabbix_agentd
[root@web ~]# zabbix_agentd 
[root@web ~]# ss -anlt
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                   [::]:22                  [::]:*                 
[root@web ~]# 


//安装httpd服务
[root@web ~]# yum -y install httpd
[root@web ~]# systemctl start httpd
[root@web ~
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值