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

401 Unauthorized should not be OK #75

Closed erikdsjostrom closed 7 months ago

erikdsjostrom commented 2 years ago

Pretty much the title. There is no indication to the user if a request is not authorized, instead giving an OK exit code. This could lead to false monitoring data if the user does not realize their mistake.

martialblog commented 2 years ago

Hi,

I just tested this with a simple Flask app and it seems to me that everything works as expected:

curl -i http://localhost:5000/examples

HTTP/1.1 401 UNAUTHORIZED
Server: Werkzeug/2.2.2 Python/3.10.4
Date: Fri, 09 Sep 2022 14:33:35 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 19
WWW-Authenticate: Basic realm="Authentication Required"
Connection: close
./check_http_json.py -H localhost:5000 -p examples -w "examples.(0).capacity.value,1000" 
UNKNOWN: Status UNKNOWN. HTTPError[401], url:http://localhost:5000/examples 
Parser error: Expecting value: line 1 column 1 (char 0)

echo $? 
3
martialblog commented 7 months ago

I'm closing this due to lack of feedback. Can be reopened when further information is provided.