Hello guys,
a little contribution from myself, a simple/quick script to monitor your cluster, tested on centos 7 / ES 7.11.2
You can easily cron it :
*/5 * * * * /root/ES_health.sh >> /root/ES_health.log
ES_health.sh
#!/bin/sh
HOST=`hostname`;
RESULT=`curl -s -XGET 'http://masterip:9200/_cluster/stats?pretty=true' -u elastic:pwd | grep -i "\"status\" : \"green\"" | wc -l`
DIAG=`curl -s -XGET 'http://masterip:9200/_cluster/stats?pretty=true' -u elastic:pwd`
CURDATE=`date "+%Y/%m/%d %H:%M:%S"`;
if [[ $RESULT != "1" ]]
then
# if status not green
echo "$CURDATE : $RESULT";
# notify ENABLED
echo $DIAG | mail -s "$HOST ES cluster KO" me@gmail.com
else
# if status green
echo "$CURDATE : $RESULT";
# notify DISABLED
#echo $DIAG | mail -s "$HOST ES cluster OK" me@gmail.com
fi