Home Directory Plugins Clustering and High-Availability check_elasticsearch_health (edouard.lamoine)

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_elasticsearch_health (edouard.lamoine)

Rating
8 votes
Favoured:
0
Current Version
1.0
Last Release Date
2015-05-27
License
Other
Hits
14142
Files:
FileDescription
check_elasticsearch_healthcheck_elasticsearch_health
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!
check_elasticsearch_health (edouard.lamoine)
Check the elasticsearch cluster health (local or remote) by connecting to it's status page.

Tested under Ubuntu 10
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)
bycheteverett, January 6, 2017
1 of 1 people found this review helpful
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'
byynux, April 7, 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

bybluethundr, January 3, 2016
0 of 2 people found this review helpful
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) ?