用于Nagios中监控elasticsearch健康状态脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于Nagios中监控elasticsearch健康状态脚本相关的知识,希望对你有一定的参考价值。
在Nagios社区中上找了下相关用于监控elasticsearch索引的脚本,再经过修改下,可以在平时用于传入elasticsearch的监听ip用于在Nagios中使用监控elasticsearch健康状态的脚本
#!/bin/bash #check_elasticsearch_health.sh #Memo for Nagios outputs STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 #Position parameter judgment if [ $# -lt 1 ];then echo "Please enter host address" echo "ex> $0 HOST_ADDRESS" exit $STATE_UNKNOWN fi if [ $# -gt 1 ]; then echo "The input host address are too much" echo "ex> $0 localhost" exit $STATE_UNKNOWN fi type curl >/dev/null 2>&1 || { echo >&2 "This plugin require curl but it‘s not installed."; exit $STATE_UNKNOWN; } #检查是否有安装curl HOST=$1 STATUS=$(curl -s $HOST:9200/_cluster/health?pretty | grep status | awk ‘{print $3}‘ | cut -d\" -f2) #单节点的健康检测,平时可以根据需要监控内容来修改api获取相应的值 if [[ $STATUS && "$STATUS" != "green" ]]; then echo "CRITICAL - Status is $STATUS" exit $STATE_CRITICAL fi if [[ "$STATUS" == "green" ]]; then echo "OK - Status is $STATUS" exit $STATE_OK fi echo "UNKNOW - No data were returned by elastisearch on host $HOST" exit $STATE_UNKNOWN
本文出自 “Jim的技术随笔” 博客,谢绝转载!
以上是关于用于Nagios中监控elasticsearch健康状态脚本的主要内容,如果未能解决你的问题,请参考以下文章