Skip to content

Commit

Permalink
Merge pull request anchor#31 from tpherndon/master
Browse files Browse the repository at this point in the history
Add option to make a yellow condition issue a critical alert
  • Loading branch information
olorin committed Jun 12, 2015
2 parents 6139af7 + 2036369 commit 9072126
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```

Expand Down
8 changes: 8 additions & 0 deletions check_elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
#
Expand Down

0 comments on commit 9072126

Please sign in to comment.