导航

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

Posted on 2015-11-08 21:05  ggzone  阅读(127)  评论(0编辑  收藏  举报

监测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

printf $?


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

zabbix_agentd -t check.server[8080]