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