mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-11-25 11:53:55 +01:00
Allow multiple key value specification
Multiple key values can be specified by using colon delimiter.
This commit is contained in:
parent
15c5075cc1
commit
b9d03c899f
@ -67,7 +67,8 @@ optional arguments:
|
||||
Basic auth string "username:password"
|
||||
-p PATH, --path PATH Path.
|
||||
-e [KEY_LIST [KEY_LIST ...]], --key_exists [KEY_LIST [KEY_LIST ...]]
|
||||
Checks existence of these keys to determine status.
|
||||
Checks existence of these keys to determine status. Multiple key values can
|
||||
be delimited with colon (key,value1:value2).
|
||||
-q [KEY_VALUE_LIST [KEY_VALUE_LIST ...]], --key_equals [KEY_VALUE_LIST [KEY_VALUE_LIST ...]]
|
||||
Checks equality of these keys and values (key,value
|
||||
key2,value2) to determine status.
|
||||
|
@ -75,7 +75,7 @@ class JsonHelper:
|
||||
else:
|
||||
return (None, 'not_found')
|
||||
|
||||
def equals(self, key, value): return self.exists(key) and str(self.get(key)) == value
|
||||
def equals(self, key, value): return self.exists(key) and str(self.get(key)) in value.split(':')
|
||||
def lte(self, key, value): return self.exists(key) and float(self.get(key)) <= float(value)
|
||||
def gte(self, key, value): return self.exists(key) and float(self.get(key)) >= float(value)
|
||||
def exists(self, key): return (self.get(key) != (None, 'not_found'))
|
||||
@ -193,7 +193,8 @@ def parseArgs():
|
||||
parser.add_argument('-e', '--key_exists', dest='key_list', nargs='*',
|
||||
help='Checks existence of these keys to determine status.')
|
||||
parser.add_argument('-q', '--key_equals', dest='key_value_list', nargs='*',
|
||||
help='Checks equality of these keys and values (key,value key2,value2) to determine status.')
|
||||
help='Checks equality of these keys and values (key,value key2,value2) to determine status.\
|
||||
Multiple key values can be delimited with colon (key,value1:value2)')
|
||||
parser.add_argument('-l', '--key_lte', dest='key_lte_list', nargs='*',
|
||||
help='Checks that these keys and values (key,value key2,value2) are less than or equal to\
|
||||
the returned json value to determine status.')
|
||||
|
Loading…
Reference in New Issue
Block a user