Build precise queries to find exactly what you need
Press ESC to close
Join our next live webinar: “Advanced Nagios Monitoring Techniques” – Register Now
Your review has been submitted and is pending approval.
Check the elasticsearch cluster health (local or remote) by connecting to it’s status page.
Tested under Ubuntu 10
Current Version
1.0
Last Release Date
2015-05-27
Owner
Edouard Lamoine
License
Other
Compatible With
Plugin made by Edouard Lamoine This plugin allow you to check the Elasticsearch cluster health by connecting to it's status page. Copy the plugin in the nagios plugins directory USAGE: ./check_elasticsearch_health HOST_ADDRESS ex: ./check_elasticsearch_health localhost Return OK if returned a green status, CRITICAL if not green, UNKNOWN if returned anything -Note: This plugin won't work if curl is not installed. -And of course be sure Nagios user is allowed to access the plugin (use chmod to make it readable by Nagios user) Let me know if you experience any problem with it.
The elasticsearch cat API (since at least v2.x) supports asking for simple status -- this will return just green / yellow / red: http://localhost:9200/_cat/health?h=st'
We also use Shield, and are using this now: --- #!/bin/bash ################################################################# # Creation: Edouard Lamoine # Last Modification: 27 mai 2015 # This script is verifying the elasticsearch status # # USAGE: ./check_elasticsearch_health HOST_ADDRESS # # ex: ./check_elasticsearch_health localhost # with Shield: # ./check_elasticsearch localhost monitoring_user secret password # # ################################################################# #Memo for Nagios outputs #STATE_OK=0 #STATE_WARNING=1 #STATE_CRITICAL=2 #STATE_UNKNOWN=3 type curl >/dev/null 2>&1 || { echo >&2 "This plugin require curl but it's not installed."; exit 3; } function usage { echo "Usage: $(basename $0) HOST_ADDRESS USERNAME PASSWORD" } HOST=$1 USERNAME=$2 PASSWORD=$3 if [ -z $USERNAME -a -z $PASSWORD ] then CREDENTIALS="" else CREDENTIALS=" -u $USERNAME:$PASSWORD" fi STATUS=`/usr/bin/curl $CREDENTIALS -s $HOST:9200/_cluster/health?pretty|grep status|awk '{print $3}'|cut -d" -f2` if [[ $STATUS && "$STATUS" != "green" ]]; then echo "CRITICAL - Status is $STATUS" exit 2 fi if [[ "$STATUS" == "green" ]]; then echo "OK - Status is $STATUS" exit 0 fi echo "UNKNOWN - No data were returned by elastisearch on host $HOST" exit 3
Thanks for sharing ! Definitively a good solution for password-protected servers
I can't get this to work! This is how I'm trying: #./check_elasticsearch_health localhost CRITICAL - Status is 401 [root@logs:~] # I think it's because I have shield in place: #curl -uadmin:$ES_PASS localhost:9200/_cluster/health?pretty { "cluster_name" : "elasticsearch", "status" : "green", "timed_out" : false, "number_of_nodes" : 3, "number_of_data_nodes" : 3, "active_primary_shards" : 14, "active_shards" : 28, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 } If I remove shield (temporarily) I can get a status: #./check_elasticsearch_health localhost CRITICAL - Status is yellow Does the script work with shield? What are the flags I can pass to it?
Your shield is blocking the script from accessing Elasticsearch status page Try running plugin as root, or add exception in your shield conf. The script don't take any flags, do you consider yellow state as acceptable state (OK status for Nagios) ?
You must be logged in to submit a review.
To:
From: