您的位置:首页 > 运维架构 > 网站架构

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

2015-11-08 21:05 645 查看

监测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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: