Clustering and High-Availability

check_elasticsearch_health (edouard.lamoine)

Description:

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

Compatible With

License

Other


Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Project Files
Project Photos
Project Notes
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.
Reviews (3) Add a Review
Why not use minimal syntax?
by cheteverett, January 31, 2017
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'
1 of 1 found this review helpful.
Helpful? Yes 1 No 0
with username:password
by ynux, April 30, 2016
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
Owner's Reply:

Thanks for sharing ! Definitively a good solution for password-protected servers


Helpful? Yes  No 
can't get check_elasticsearch_health to work
by bluethundr, January 31, 2016
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?
Owner's Reply:

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) ?


0 of 2 found this review helpful.
Helpful? Yes  No 2
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4 (8)
Favorites
0
Views
13,910