2019独角兽企业重金招聘Python工程师标准>>>
通过externalscripts监控redis server的状态
externalscripts 脚本
#cat es_status.sh #放在externalscripts路径下,zabbix用户可执行
#!/bin/bash
server=$1
check=$2
if [ $check == "nodename" ] || [ $check == "clustername" ] || [ $check == "clusterstatus" ] || [ $check == "nodesnum" ] || [ $check == "datanodesnum" ]
then
case $check in
nodename)
curl http://$server/ 2>&1|grep "\"name\" :"|awk -F'"' '{print $4}' |tac|head -n 1
;;
clustername)
curl http://$server/_cluster/health?pretty 2>&1|grep ^" \"cluster_name\" :"|awk -F'"' '{print $4}'|tac|head -n 1
;;
clusterstatus)
curl http://$server/_cluster/health?pretty 2>&1|grep ^" \"status\" :"|awk -F'"' '{print $4}'|tac|head -n 1
;;
nodesnum)
curl http://$server/_cluster/health?pretty 2>&1|grep ^" \"number_of_nodes\" :"|awk -F" " '{print $3}'|sed 's/,//'|tac|head -n 1
;;
datanodesnum)
curl http://$server/_cluster/health?pretty 2>&1|grep ^" \"number_of_data_nodes\" :"|awk -F" " '{print $3}'|sed 's/,//'|tac|head -n 1
;;
esac
else
echo "not support $3."&&exit 1
fi
监控模板如下
2.0
2016-04-01T08:20:37Z
Templates
template elasticsearch
template elasticsearch
Templates
elasticsearch
-
elasticsearch $1 cluster name
10
0
es_status.sh[{IPADDRESS}:9200,clustername]
60
90
365
0
4
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $1 cluster status
10
0
es_status.sh[{IPADDRESS}:9200,clusterstatus]
60
90
365
0
4
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $1 data nodes num
10
0
es_status.sh[{IPADDRESS}:9200,datanodesnum]
60
90
365
0
3
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $1 node name
10
0
es_status.sh[{IPADDRESS}:9200,nodename]
60
90
365
0
4
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $1 nodes num
10
0
es_status.sh[{IPADDRESS}:9200,nodesnum]
60
90
365
0
3
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $2 port 9200 check
3
0
net.tcp.service[tcp,{IPADDRESS},9200]
60
90
365
0
3
0
0
0
0
1
0
0
0
elasticsearch
-
elasticsearch $2 port 9300 check
3
0
net.tcp.service[tcp,{IPADDRESS},9300]
60
90
365
0
3
0
0
0
0
1
0
0
0
elasticsearch
{template elasticsearch:es_status.sh[{IPADDRESS}:9200,nodesnum].diff()}=1 or {template elasticsearch:es_status.sh[{IPADDRESS}:9200,datanodesnum].diff()}=1
elasticsearch {IPADDRESS} data nodes or nodes number changed.
0
3
0
{template elasticsearch:net.tcp.service[tcp,{IPADDRESS},9200].last()}<>1
elasticsearch {IPADDRESS} port 9200 check failed.
0
3
0
{template elasticsearch:net.tcp.service[tcp,{IPADDRESS},9300].last()}<>1
elasticsearch {IPADDRESS} port 9300 check failed.
0
3
0
{template elasticsearch:es_status.sh[{IPADDRESS}:9200,clusterstatus].str(green,#1)}<>1
elasticsearch {IPADDRESS} status error
0
3
0