Http check returns 200 OK even if the status 404

Hi,

I am trying to set a http check. It always gives back 200 OK in server response, even if I have a 404. On my check_mk server:

# ./check_http --expect=200 --ssl my.host.com
HTTP OK: Status line output matched "200" - 75414 bytes in 0.268 second response time |time=0.267687s;;;0.000000;10.000000 size=75414B;;;0

The active http check in WATO behaves the same of course, at the same time the web host gives 404:

$ curl https://my.host.com

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>404 Bad Request</title>
  </head>
  <body>
    <h1>Error 404 Bad Request</h1>
    <p>Bad Request</p>
    <h3>Guru Mediation:</h3>
    <p>Details: cache-hhn4059-HHN 1615531030 2040292555</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>

And here is a screen shot:

Screenshot from 2021-03-12 07-37-47

How can I get the http check to work?

Thanks a lot.

Can you make your curl command with an “-v” to see the real header.
That is what your check looks for.

*   Trying 192.168.1.1:80...
* TCP_NODELAY set
* Connected to www.my-server.com (192.168.1.1) port 80 (#0)
> GET /fake HTTP/1.1
> Host: www.my-server.com
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Server: nginx/1.19.0
< Date: Fri, 12 Mar 2021 06:56:33 GMT
< Content-Type: text/html; charset=iso-8859-1
< Content-Length: 196
< Connection: keep-alive

If you don’t see the 404 there in the response than it is clear that the check will not work.
In this case you can search for 404 in the content of the page.

Hi Andreas,

I see the 404:

* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 404 
< server: Varnish
< retry-after: 0
< content-type: text/html; charset=utf-8

But which parameters do I need to make the http_check sees it as well. I tried different things but the check gives always 200 OK.

HTTP OK: Status line output matched "200 OK" - 7913 bytes in 0.516 second response time

You may need to add -H my.host.com (option Virtual Host in WATO)

See the screenshot below, which also uses the $HOSTNAME$ macro, assuming your host in CheckMK is also named my.host.com.

image

The issue was solved few hours ago by itself, I don’t know what was the Problem. Thanks you for the suggestion.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.