mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-12-22 09:03:57 +01:00
added ability to reference array elements when the root element is an array
This commit is contained in:
parent
9aa7ed57aa
commit
82f4eaa48a
14
README.md
14
README.md
@ -97,6 +97,20 @@ optional arguments:
|
||||
Access a specific JSON field by following this syntax: `alpha.beta.gamma(3).theta.omega(0)`
|
||||
Dots are field separators (changeable), parantheses are for entering arrays.
|
||||
|
||||
If the root of the JSON data is itself an array like the following:
|
||||
|
||||
```
|
||||
[
|
||||
{ "gauges": { "jvm.buffers.direct.capacity": {"value1": 215415}}}
|
||||
]
|
||||
```
|
||||
|
||||
The beginning of the key should start with ($index) as in this example:
|
||||
|
||||
```
|
||||
./check_http_json.py -H localhost:8081 -p metrics --key_exists "(0)_gauges_jvm.buffers.direct.capacity_value" -f _
|
||||
```
|
||||
|
||||
More info about Nagios Range format and Units of Measure can be found at [https://nagios-plugins.org/doc/guidelines.html](https://nagios-plugins.org/doc/guidelines.html).
|
||||
|
||||
### Docker Info Example Plugin
|
||||
|
@ -70,7 +70,10 @@ class JsonHelper:
|
||||
else:
|
||||
return (None, 'not_found')
|
||||
else:
|
||||
return (None, 'not_found')
|
||||
if not subElemKey:
|
||||
return self.get(remainingKey, data[index])
|
||||
else:
|
||||
return (None, 'not_found')
|
||||
|
||||
def equals(self, key, value): return self.exists(key) and str(self.get(key)) == value
|
||||
def lte(self, key, value): return self.exists(key) and float(self.get(key)) <= float(value)
|
||||
|
Loading…
Reference in New Issue
Block a user