drewkerrigan / nagios-http-json

A generic plugin for Nagios which checks json values from a given HTTP endpoint against argument specified rules and determines the status and performance data for that service.
Other
67 stars 60 forks source link

translate working curl into correct attributes #71

Closed greyslater closed 2 years ago

greyslater commented 3 years ago

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

martialblog commented 3 years ago

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

martialblog commented 2 years ago

Hey, might this be what you need? https://github.com/drewkerrigan/nagios-http-json/pull/79

martialblog commented 2 years ago

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