Wildcard for nagios-http-json keys

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
MitchelBrayon
Posts: 4
Joined: Mon Jul 25, 2022 6:35 am

Wildcard for nagios-http-json keys

Post by MitchelBrayon »

Looking to use the nagios plugin nagios-http-json https://github.com/drewkerrigan/nagios-http-json to check a json response.

There is an example (I slightly modified):

Data for keys ring_members(0).numberToCheck, ring_members(1).numberToCheck, ring_members(2).numberToCheck:
{
"ring_members": [
{"numberToCheck": "10"},
{"numberToCheck": "20"},
{"numberToCheck": "30"}
]
}
If I want to check the first element in the response's array I could write:

plugins/check_http_json.py .... -w ring_members(0).numberToCheck,@20:
To check if ring_members position 0 key numberToChecks value is greater than or equal to 20 and flag a warning if true.

I could repeat -w ring_members(0).numberToCheck,@20: ring_members(1).numberToCheck,@20: ... to check all the values.

However is it possible to check each position of ring_members, when the length of ring_members is unknown?
Post Reply