# Simple elastic search cluster monitoring

**URL:** https://discuss.elastic.co/t/simple-elastic-search-cluster-monitoring/271656
**Category:** Elasticsearch
**Tags:** elastic-stack-monitoring
**Created:** [April 29, 2021, 1:52pm UTC](https://discuss.elastic.co/t/simple-elastic-search-cluster-monitoring/271656 "2021-04-29T13:52:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![webfr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webfr/32/87580_2.png) [@webfr](https://discuss.elastic.co/u/webfr)
#### Post date: [April 29, 2021, 1:52pm UTC](https://discuss.elastic.co/t/simple-elastic-search-cluster-monitoring/271656/1 "2021-04-29T13:52:28Z")

</div>

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
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 27, 2021, 1:52pm UTC](https://discuss.elastic.co/t/simple-elastic-search-cluster-monitoring/271656/2 "2021-05-27T13:52:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
