Check ElasticSearch Cluster Status

Bash script to check health of ElasticSearch service running in an Ubuntu server. This script send an email alert to a ticketing system alerting if service status is not running. After sending the email, this script tries to restart ES service again and push status logs.

#!/bin/bash
check2=`curl -s localhost:9200 | grep "cluster_name"`
if [[ $check2 == *"cluster_name"* ]]
then
        stat='status check at, '
        stime=`uptime`
        dte=`date`
        str=$check2$stat$dte$stime
        echo $str >> /var/log/elastic_status.txt
else
        stat='status failed at, '
        stime=`uptime`
        dte=`date`
        str=$stat$dte$stime
        echo $str >> /var/log/elastic_status.txt
        echo $str | mail -s "elasticsearch crash" -r noreply@cluster.com monit@tickets.com
        systemctl start elasticsearch
        stime1=`uptime`
        msg='restarting service at ... '
        retry=$msg$dte$stime1
        echo $retry >> /var/log/elastic_status.txt

fi
Previous
Previous

Configure AWS CLI

Next
Next

Postfix config for SES in Linux