Check the health status of elasticsearch instance, sends an email if the response status is not 200.
You can run this with cronjob, creates a file to do not send the email multiple times if the server is down.

Note : Change the ‘host-elastic-server’ to your elasticsearch instance IP.

status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://host-elastic-server:9200/_cluster/health)
if [[ ( "$status_code" -ne 200 ) && ( ! -f ${mailSentFileFlag} ) ]] ; then
  echo "Elasticsearch is down. Status code $status_code" | mail -s "Elasticsearch monior" "," -r "ElasticSearch Monitor"
  echo "yeah"
  touch ${mailSentFileFlag}
  exit 0