drewkerrigan/nagios-http-json

translate working curl into correct attributes

Closed this issue · 3 comments

I really tried my best:
curl is working perfect but check-http-json.py gives ConnectionResetError: [Errno 104] Connection reset by peer

curl --insecure --cert ~/private.crt --key ~/private.key -d '{}' -H "Content-Type: application/json" -X POST https://localhost:8567/info

check_http_json.py --debug --ssl --host localhost:8567 --insecure --cert ~/private.crt --key ~/private.key --path info --headers '{"content-type": "application/json"}' --key_exists success

I'm sure it's the -d '{}' from curl but I'm not allowed to use --data '{}' with the nagios-plugin here as there will be error
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

As far as I understood POST method is only used in connection with --data
otherwise it's always GET method

help is highly appreciated

Hey, I'm super busy at the moment, so it might take a while for me to look at this. Sorry 😞

Hey, might this be what you need? #79

The new release offers a flag to change the HTTP Method

/check_http_json.py -H 127.0.0.1:5000 -p postme -E "examples.(0).capacity" 
UNKNOWN: Status UNKNOWN. HTTPError[405], url:http://127.0.0.1:5000/postme Parser error: Expecting value: line 1 column 1 (char 0)

check_http_json.py -X POST -H 127.0.0.1:5000 -p postme -E "examples.(0).capacity"
OK: Status OK.

If this doesn't is what you need. Just reopen the issue.

Cheers
Markus