ES_AutoCheck.sh

#!/bin/bash
#@es_check
#@date 2019/11/26
#@auth tigergao
status=`curl  -s GET "http://172.16.71.100:10290/_cat/health?" | awk '{print $4}'`
 if [ $status == green ];then
  echo "ES集群状态正常!"
 fi

 if [ $status == yellow ];then
  echo "ES集群状态为yellow,请检查副本分片是否可用!"
 fi

 if [ $status == red ];then
  echo "ES集群状态已经挂掉,请尽快修复!"
 fi

num1=`curl -s GET "http://172.16.71.100:10290/_cat/indices?" | grep -i apollo  | awk '{print $1}' | grep -v green | wc -l`
 if [ $num1 -eq 0 ];then
  echo "阿波罗索引全部正常,请放心"
 else
  echo "阿波罗索引有异常,请尽快查看"
 fi

num2=`curl -s GET "http://172.16.71.100:10290/_cat/indices?"  | grep -i zeus  | awk '{print $1}' | grep -v green | wc -l`
 if [ $num2 -eq 0 ];then
  echo "zeus索引全部正常,请放心"
 else
  echo "zeus索引有异常,请尽快查看"
 fi

curl -XGET -H "Content-Type: application/json" http://172.16.71.100:10290/_cat/nodes?v

  

posted @ 2020-12-24 22:07  tigergaonotes  阅读(68)  评论(0编辑  收藏  举报