Closed pvvqla closed 2 years ago
Hi,
Is this what you are trying to do?
curl http://localhost:8000/bytes-ok.json
[
{
"memory": [{"availableBytes": 231}]
},
{
"memory": [{"availableBytes": 321}]
},
{
"memory": [{"availableBytes": 123}]
}
]
curl http://localhost:8000/bytes-not-ok.json
[
{
"memory": [{"availableBytes": 123}]
},
{
"memory": [{"availableBytes": 231}]
},
{
"memory": []
}
]
./check_http_json.py -H localhost:8000 -p bytes-ok.json -E "(*).memory(0).availableBytes"
OK: Status OK.
./check_http_json.py -H localhost:8000 -p bytes-not-ok.json -E "(*).memory(0).availableBytes"
CRITICAL: Status CRITICAL. Key (2).memory(0).availableBytes did not exist.
Needs feedback. Can be reopened if necessary
Hello,
When I am trying to select all keys of an json api using this syntax (*).capacity.value I have this error:
File "./check_http_json.py", line 433, in
nagios.append_metrics(processor.checkMetrics())
File "./check_http_json.py", line 246, in checkMetrics
if self.helper.exists(key):
File "./check_http_json.py", line 104, in exists
def exists(self, key): return (self.get(key) != (None, 'not_found'))
File "./check_http_json.py", line 115, in get
return self.getSubElement(key, data)
File "./check_http_json.py", line 78, in getSubElement
return self.get(remainingKey, data[partialKey])
File "./check_http_json.py", line 117, in get
return self.getSubArrayElement(key, data)
File "./check_http_json.py", line 84, in getSubArrayElement
index = int(key[key.find(self.arrayOpener) + 1:key.find(self.arrayCloser)])
ValueError: invalid literal for int() with base 10: ''
[root@eyes2 plugins]# ./check_http_json.py -H localhost:3010 -p data -m imdata.().eqptStorage.attributes.available
If i use an integer like imdata.(0).eqptStorage.attributes.available it works.
How can i select all the keys in a json file?
Thank you.