A script for monitoring the Elasticsearch index was found in the Nagios community, and then modified to use the listening IP that is normally used for incoming elasticsearch for using a script that monitors the Elasticsearch health state in Nagios
#!/bin/bash#check_elasticsearch_health.sh#memo for nagios outputsstate_ok=0state_warning=1state _critical=2state_unknown=3#position parameter judgmentif [ $# -lt 1 ];then echo "Please enter host address" echo "Ex> $0 host_address" exit $STATE _unknownfiif [ $# -gt 1 ]; then echo "The input host address are too much " echo " Ex> $0 localhost " exit $STATE _unknownfitype curl >/dev/null 2>&1 | | { echo >&2 "This plugin require curl but it ' S not installed. "; exit $STATE _unknown; } #检查是否有安装curlHOST =$1status=$ (curl -s $HOST: 9200/_cluster/health ? pretty | grep status | awk ' {print $3} ' | cut -d\ " -f2) # Single-node health detection, usually can monitor the content according to need to modify the API to get the corresponding value if [[ $STATUS && "$STATUS" != "green" ]]; thenecho "critical - status is $STATUS" exit $STATE _criticalfiif [[ "$STATUS" == "green" ]]; thenecho "ok - status is $ STATUS "exit $STATE _okfiecho " unknow - no data were returned by elastisearch on host $HOST "exit $STATE _unknown
This article from "Jim's Technical Essay" blog, declined to reprint!
For monitoring Elasticsearch health status scripts in Nagios