sensu-plugins / sensu-plugins-http

This plugin provides native HTTP instrumentation for monitoring and metrics collection, including: response code, JSON response, HTTP last modified, SSL expiry, and metrics via `curl`.
http://sensu-plugins.io
MIT License
30 stars 96 forks source link

check_http.rb: Whole response option prints whole response even if the check is successful #85

Open mfornasa opened 6 years ago

mfornasa commented 6 years ago
    -w, --whole-response             Print whole output when check fails

-w prints HTTP body even if the check is successful.

jplindquist commented 6 years ago

To me, the option seems to imply that the whole response should be returned regardless of the response code when the check fails. Currently it looks like this setting only returns the body if the status != 2xx. I don't know if this is an old issue that's still valid or not, so I don't mean to hijack it, but I would like to also have this option include the body not only on when we get a non 2xx response, but also if the expected key is not found, or does not meet one of the conditions specified.

@majormoses Would you be open to a PR that updates how this option works to include the response on other failures as well?

majormoses commented 6 years ago

Man that check is a mess, I guess that's what happens when you try to implement curl and every monitoring use case around it without proper design.

Based on the description of the check option I would assume that it should print the body when status != "ok" meaning for warning, critical, or unknown statuses which has nothing to do with status codes. The function that generates it should always return the whole body put that does not mean it is printed until the status is evaluated.

I think there are use cases to assert that something intentionally does not exist, that something redirects, etc which would be a non 200 response which leads me to think that this should be a per status configurable setting.