diff --git a/README.md b/README.md index 6da624b..0276be5 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,11 @@ Options: do not monitor the number of nodes in the cluster. -p PORT, --port=PORT TCP port to probe. The ElasticSearch API should be listening here. Defaults to 9200. + -y YELLOW_CRITICAL, --yellow-critical=TRUE + Instead of issuing a 'warning' for a yellow cluster + state, issue a 'critical' alert. Allows for greater + control of alerting for clusters that may be of + greater sensitivity (or fragility). Defaults to False. ``` diff --git a/check_elasticsearch b/check_elasticsearch index e6ed228..a1d39a2 100755 --- a/check_elasticsearch +++ b/check_elasticsearch @@ -89,6 +89,9 @@ class ElasticSearchCheck(NagiosCheck): "Optional prefix (e.g. 'es') for the " "ElasticSearch API. Defaults to ''.") + self.add_option('y', 'yellow-critical', 'yellow_critical', + "Have plugin issue critical alert on yellow cluster state. Defaults to False.") + def check(self, opts, args): host = opts.host or "localhost" port = int(opts.port or '9200') @@ -110,6 +113,11 @@ class ElasticSearchCheck(NagiosCheck): except ValueError: raise UsageError("Argument to -m/--master-nodes must " "be a natural number") + + yellow_critical = opts.yellow_critical and opts.yellow_critical.lower() not in ('f', 'false', 'n', 'no') + if yellow_critical: + HEALTH_MAP[1] = 'critical' + # # Data retrieval #