diff --git a/README.md b/README.md index 63c06c5..c409ef5 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,9 @@ optional arguments: (key,value1:value2). Return warning if equality check fails -Q [KEY_VALUE_LIST_CRITICAL [KEY_VALUE_LIST_CRITICAL ...]], --key_equals_critical [KEY_VALUE_LIST_CRITICAL [KEY_VALUE_LIST_CRITICAL ...]] - Same as -q but return critical if equality check - fails. + Same as -q but return critical if equality check fails. + -u [KEY_VALUE_LIST_UNKNOWN [KEY_VALUE_LIST_UNKNOWN --key_equals_unknown [KEY_VALUE_LIST_UNKNOWN [KEY_VALUE_LIST_UNKNOWN ...]] + Same as -Q but return unknown if equality check fails. -m [METRIC_LIST [METRIC_LIST ...]], --key_metric [METRIC_LIST [METRIC_LIST ...]] Gathers the values of these keys (key[>alias],UnitOfMe asure,WarnRange,CriticalRange,Min,Max) for Nagios diff --git a/check_http_json.py b/check_http_json.py index 011d689..2fbeddb 100755 --- a/check_http_json.py +++ b/check_http_json.py @@ -305,6 +305,12 @@ class JsonRuleProcessor: failure += self.checkExists(self.key_list_critical) return failure + def checkUnknown(self): + unknown = '' + if self.rules.key_value_list_unknown != None: + unknown += self.checkEquality(self.rules.key_value_list_unknown) + return unknown + def checkMetrics(self): """Return a Nagios specific performance metrics string given keys and parameter definitions""" @@ -403,6 +409,10 @@ def parseArgs(): dest='key_value_list_critical', nargs='*', help='''Same as -q but return critical if equality check fails.''') + parser.add_argument('-u', '--key_equals_unknown', + dest='key_value_list_unknown', nargs='*', + help='''Same as -q but return unknown if + equality check fails.''') parser.add_argument('-m', '--key_metric', dest='metric_list', nargs='*', help='''Gathers the values of these keys (key[>alias], UnitOfMeasure,WarnRange,CriticalRange,Min,Max) for @@ -646,6 +656,7 @@ if __name__ == "__main__": nagios.append_warning(processor.checkWarning()) nagios.append_critical(processor.checkCritical()) nagios.append_metrics(processor.checkMetrics()) + nagios.append_unknown(processor.checkUnknown()) # Print Nagios specific string and exit appropriately print nagios.getMessage() exit(nagios.getCode())