Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_http: Unchunking body fails when no body is present #1872

Closed
AiYoriAoshi opened this issue Apr 18, 2023 · 11 comments
Closed

check_http: Unchunking body fails when no body is present #1872

AiYoriAoshi opened this issue Apr 18, 2023 · 11 comments

Comments

@AiYoriAoshi
Copy link

Checks with -N / --no-body fail with 2.3.3

# /usr/local/nagios/libexec/check_http -I <IP> -4 -N -v
GET / HTTP/1.0
User-Agent: check_http/v2.3.3 (monitoring-plugins 2.3.3)
Connection: close


http://<IP>:80/ is 1460 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Cache-Control: must-revalidate,public
Last-Modified: Tue, 18 Apr 2023  08:44:27 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: Keep-Alive
**** CONTENT ****
  [[ skipped ]]
Found chunked content
Chunked content did not start with a number at all (Line: 1415)
HTTP UNKNOWN: Failed to unchunk message body

as mentioned in 1815

Adding !no_body to the if as suggested fixes the problem for me.

@mike1356
Copy link

mike1356 commented Apr 27, 2023

Adding !no_body to the if at line 1281 fixes it for me as well.

# /opt/plugins/check_http -H <IP> -p <port> -u /api/v1/health -N -v
GET /api/v1/health HTTP/1.1
User-Agent: check_http/v2.3git (monitoring-plugins 2.3git)
Connection: close
Host: <IP>:<port>

http://<IP>:<port>/api/v1/health is 128 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Server: Monkey/1.7.0
Date: Thu, 27 Apr 2023 11:59:14 GMT
Connection: Close
Transfer-Encoding: chunked
**** CONTENT ****
  [[ skipped ]]
HTTP OK: HTTP/1.1 200 OK - 128 bytes in 0.002 second response time |time=0.002058s;;;0.000000;10.000000 size=128B;;;0;

@RincewindsHat
Copy link
Member

I will take a look at it. Until then, you could use check_curl as a replacement.

@moschlar
Copy link

moschlar commented Jun 9, 2023

It seems to me that the server is sending:
Transfer-Encoding: chunked but no Content-Length: 0.

(The server being IIS...)

@trickert76
Copy link
Contributor

The problem is, that the parameter -N (--no-body) removes any kind of response after the header, but this commit seven months ago only reads the body and doesnt check, if the parameter --no-body is present.

@trickert76
Copy link
Contributor

So, this is not a bug from the HTTP server (in my case an nginx). Its a bug in the way the new code for chunked content is handling requests when --no-body is defined. There is already a fix documented but not merged.

trickert76 added a commit to trickert76/monitoring-plugins that referenced this issue Aug 8, 2023
@juliogonzalez
Copy link

@trickert76 your patch seems to fix the issue for me. Thanks!

Maybe you should prepare a PR against https://github.com/monitoring-plugins/monitoring-plugins?

#1806 suggest that maybe check_http will be removed and it's mention that maybe new features should not be affected, but bugfixing should be OK.

@waja
Copy link
Member

waja commented Sep 15, 2023

This should be fixed with #1901, isn't it?

@RincewindsHat
Copy link
Member

@waja I think it is, but I am not completely sure, that everything is handled correctly if the server sends an empty body and nobody is not chosen.

@waja
Copy link
Member

waja commented Sep 15, 2023

@trickert76 your patch seems to fix the issue for me. Thanks!

Maybe you should prepare a PR against https://github.com/monitoring-plugins/monitoring-plugins?

#1806 suggest that maybe check_http will be removed and it's mention that maybe new features should not be affected, but bugfixing should be OK.

a6802bd is exactly what #1815 (comment) is suggesting. So if that's the only change that is needed, we don't need another PR.

Can anybody having this issue please test master (which has a6802bd merged) and verify if the issue is done? thanks!

@juliogonzalez
Copy link

juliogonzalez commented Oct 4, 2023

@waja, I just built the code from master an uploaded check_http to my checkmk instance.

It works fine after forcing a first check, but since the problem was not happening all the time in the past (at least in my case), please give me some time to confirm if it's fixed.

@juliogonzalez
Copy link

@waja, after a few days, it works for me.

So FMPOV, the bug report can be closed as solved.

Thanks a lot!

@waja waja closed this as completed Oct 11, 2023
paladox added a commit to miraheze/puppet that referenced this issue Oct 19, 2023
Also switch nginx to it.

There's a bug in check_http
monitoring-plugins/monitoring-plugins#1872.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants