nagios-http-json icon indicating copy to clipboard operation
nagios-http-json copied to clipboard

Add --base64 option to decode base64-encoded JSON responses

Open ggzengel opened this issue 6 months ago • 0 comments

Add --base64 option to decode base64-encoded JSON responses

  • Introduced the --base64 argument to the CLI.
  • When specified, the plugin decodes the HTTP response body from base64 before parsing it as JSON.
  • Maintains existing behavior if --base64 is 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.

ggzengel avatar May 15 '25 18:05 ggzengel