Zabbix自定义监控网站服务是否能够正常响应


监测tcp连接数文件名:
/etc/zabbix/zabbix_agentd.conf.d/count_tcp.conf
UserParameter=count.tcp,netstat -s|grep "connections established"|awk '{print$1}'
客户端检验自定义key是否正常:zabbix_agentd -t  count.tcp


监测服务器服务是否正常
/etc/zabbix/script/check_server.sh  设置运行权限(注意一定要给zabbix用户加上运行权限)

#!/bin/bash

#set -x

function Check_One()
{
        local run_times=3
        local fail_times=0
        while [ $run_times -gt 0 ]
        do
                #local ret=$(curl -I -m 3 -o /dev/null -s -w %{http_code} $1)
                #if [ $ret != "200" -a $ret != "300"  ]
                local ret=$(curl -s $1)
                if [[ $ret != '{"head":"ok"}' ]]
                then
                        fail_times=`expr $fail_times + 1`
                fi
                run_times=`expr $run_times - 1`
        done

        if [ $fail_times -ge 2 ]
        then
                return 0
        else
                return 1
        fi
}


HOSTS_DIR=/Users/dev-fan/erlang

Check_One http://127.0.0.1:$1
printf $?


check_server.conf内容:
UserParameter=check.server[*],/etc/zabbix/script/check_server.sh $1

zabbix_agentd -t check.server[8080]
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值