共计 1496 个字符,预计需要花费 4 分钟才能阅读完成。
在 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
CentOS 7 下安装配置 Nagios 监控图文详解 http://www.linuxidc.com/Linux/2017-05/143886.htm
Nagios 邮件报警配置简述 http://www.linuxidc.com/Linux/2017-02/140834.htm
Nagios 本机及其他主机监控安装部署详解 http://www.linuxidc.com/Linux/2017-03/141600.htm
Nagios 系统监控基本安装配置过程详解 http://www.linuxidc.com/Linux/2017-01/139758.htm
Linux 下 Nagios+PNP4Nagios 的安装与配置 http://www.linuxidc.com/Linux/2016-09/135534.htm
CentOS7 安装 Nagios 并配置出图详解 http://www.linuxidc.com/Linux/2015-12/125777.htm
Linux 下 Nagios 安装配置详解 http://www.linuxidc.com/Linux/2017-05/144032.htm
Nagios 的详细介绍 :请点这里
Nagios 的下载地址 :请点这里
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-09/146923.htm