查看es集群健康状态
curl -XGET '
{ "cluster_name" : "hotel-elk-log", "status" : "green", #集群状态:green,yellow,red "timed_out" : false, "number_of_nodes" : 3, #集群中node节点数 "number_of_data_nodes" : 2, #集群中data节点数 "active_primary_shards" : 186, "active_shards" : 372, "relocating_shards" : 0, #迁移分片到新的node "initializing_shards" : 0, #初始化分片 "unassigned_shards" : 0, # "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0}
shell 脚本
#!/bin/bashcase $1 in cluster_name) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\" '/cluster_name/ {print $4}' ;; status) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\" 'NR==3 {print $4}' ;; timed_out) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==4 {print $1}' |awk -F: '{print $2}' ;; number_nodes) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==5 {print $1}' |awk -F: '{print $2}' ;; data_nodes) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==6 {print $1}' |awk -F: '{print $2}' ;; active_primary_shards) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==7 {print $1}' |awk -F: '{print $2}' ;; active_shards) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==8 {print $1}' |awk -F: '{print $2}' ;; relocating_shards) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==9 {print $1}' |awk -F: '{print $2}' ;; initializing_shards) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==10 {print $1}' |awk -F: '{print $2}' ;; unassigned_shards) curl -s -XGET 'http://localhost:9200/_cluster/health?pretty' |awk -F\, 'NR==11 {print $1}' |awk -F: '{print $2}' ;; *) echo "Usage: $0 { cluster_name | status | timed_out | number_nodes | data_nodes | active_primary_shards | active_shards | relocating_shards | initializing_shards | unassigned_shards}" ;;esac
zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=cluster_name,/usr/local/zabbix/es_status.sh cluster_nameUserParameter=status,/usr/local/zabbix/es_status.sh statusUserParameter=timed_out,/usr/local/zabbix/es_status.sh timed_outUserParameter=number_nodes,/usr/local/zabbix/es_status.sh number_nodesUserParameter=data_nodes,/usr/local/zabbix/es_status.sh data_nodesUserParameter=active_primary_shards,/usr/local/zabbix/es_status.sh active_primary_shardsUserParameter=active_shards,/usr/local/zabbix/es_status.sh active_shardsUserParameter=relocating_shards,/usr/local/zabbix/es_status.sh relocating_shardsUserParameter=initializing_shards,/usr/local/zabbix/es_status.sh initializing_shardsUserParameter=unassigned_shards,/usr/local/zabbix/es_status.sh unassigned_shards
zabbix上添加host,链接到模板