zabbix 监控elasticsearch

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

通过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

监控模板如下

zabbix 监控elasticsearch_第1张图片

输入图片说明 导出模板的xml



    2.0
    2016-04-01T08:20:37Z
    
        
            Templates
        
    
    
        
    
    
        
            {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
            
        
    

转载于:https://my.oschina.net/u/1791060/blog/651484

你可能感兴趣的:(zabbix 监控elasticsearch)