drewkerrigan/nagios-http-json

401 Unauthorized should not be OK

erikdsjostrom opened this issue · 2 comments

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.

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

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