From 857ac85594e19d20861032b78b8297f44c0a5b9c Mon Sep 17 00:00:00 2001 From: mtwelve Date: Fri, 13 Sep 2019 18:12:10 +0100 Subject: [PATCH] An attempt to add a flag to invert the value I don't and cannot write Python but I have attempted to add a CLI argument to invert the value that is returned from the API such that we can monitor where a value should be 100% and we need alerting when it falls below that. --- check_azure_resource.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/check_azure_resource.py b/check_azure_resource.py index b17712f..63d62b5 100755 --- a/check_azure_resource.py +++ b/check_azure_resource.py @@ -80,6 +80,7 @@ def _set_cli_options(self): self.add_arg('M', 'metric', 'Metric') self.add_arg('D', 'dimension', 'Metric dimension', required=None) self.add_arg('V', 'dimension-value', 'Metric dimension value', required=None) + self.add_arg('I', 'inverse-flag', 'Inverted metric flag', required=None) def activate(self): """Parse out all command line options and get ready to process the plugin.""" @@ -201,7 +202,10 @@ def check_metric(self): if self['dimension'] is not None: message += ' and dimension {}'.format(self['dimension']) self.nagios_exit(Plugins.UNKNOWN, message) - + + if self['inverse-flag'] is not None: + value := -value; + status = Plugins.check_threshold(value, warning=self['warning'], critical=self['critical']) unit = self._AZURE_METRICS_UNIT_SYMBOLS.get(self._metric_properties['unit'])