From f69ef64fce20e1bac6d9c19c996b81c2794d485e Mon Sep 17 00:00:00 2001 From: Difrex Date: Wed, 9 Dec 2015 09:47:32 +0300 Subject: [PATCH] up/down --- plugins/graphite/graphite-metric-check.py | 31 ++++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/plugins/graphite/graphite-metric-check.py b/plugins/graphite/graphite-metric-check.py index f56f262..2069aa4 100755 --- a/plugins/graphite/graphite-metric-check.py +++ b/plugins/graphite/graphite-metric-check.py @@ -45,6 +45,13 @@ class GraphiteMetricCheck(SensuPluginCheck): type=int, help='Integer critical level to output' ) + self.parser.add_argument( + '-C', + '--critupdown', + type=str, + required=True, + help='-C ' + ) self.parser.add_argument( '-s', '--host', @@ -95,14 +102,24 @@ class GraphiteMetricCheck(SensuPluginCheck): avg = getGraphiteValue(self.options.host, self.options.port, self.options.target, self.options.from_time, self.options.to_time) - if avg > self.options.warning and avg < self.options.critical: - self.warning(self.options.target + ' ' + str(avg)) - elif avg < self.options.warning: - self.ok(self.options.target + ' ' + str(avg)) - elif avg >= self.options.critical: - self.critical(self.options.target + ' ' + str(avg)) + if self.options.critupdown == 'up': + if avg >= self.options.warning and avg < self.options.critical: + self.warning(self.options.target + ' ' + str(avg)) + elif avg < self.options.warning: + self.ok(self.options.target + ' ' + str(avg)) + elif avg >= self.options.critical: + self.critical(self.options.target + ' ' + str(avg)) + else: + self.unknown(self.options.message) else: - self.unknown(self.options.message) + if avg > self.options.critical and avg <= self.options.warning: + self.warning(self.options.target + ' ' + str(avg)) + elif avg > self.options.warning: + self.ok(self.options.target + ' ' + str(avg)) + elif avg <= self.options.critical: + self.critical(self.options.target + ' ' + str(avg)) + else: + self.unknown(self.options.message) if __name__ == "__main__": f = GraphiteMetricCheck()