nagios-http-json
nagios-http-json copied to clipboard
Add --base64 option to decode base64-encoded JSON responses
Add --base64 option to decode base64-encoded JSON responses
- Introduced the
--base64argument to the CLI. - When specified, the plugin decodes the HTTP response body from base64 before parsing it as JSON.
- Maintains existing behavior if
--base64is not used.
Example usage with Passwork
Basic call
./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST \
--header '{"Accept": "application/json", "Content-Type": "application/json"}' \
--data '{"token": "0123456789ABCD"}' --ssl --base64
Passwork responds with:
{
"format": "base64",
"content": "eyJzdGF0ZXMiOnsibW9uZ29kYiI6Im9rIiwidGFza3MiOiJvayJ9LCJlcnJvcnMiOltdfQ=="
}
The script decodes the 'content' field and parses the resulting JSON.
Advanced check with key assertions
./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST \
--header '{"Accept": "application/json", "Content-Type": "application/json"}' \
--data '{"token": "0123456789ABCD"}' --ssl --base64 content \
-Q states.mongodb,ok states.tasks,ok errors,[]
Decoded JSON:
{
"states": {
"mongodb": "ok",
"tasks": "ok"
},
"errors": []
}
Example output:
OK: Status OK.