Check_http 400 and 404 for popular websites

Hi! I need checks for external links on my website and I’m running into problems with check_http for some websites.

See these examples:

  1. www.nature.com, gives 400 Bad Request
$ check_http -I www.nature.com -v                                 
GET / HTTP/1.0
User-Agent: check_http/v2.2 (monitoring-plugins 2.2)
Connection: close


http://www.nature.com:80/ is 694 characters
STATUS: HTTP/1.1 400 Bad Request
**** HEADER ****
Connection: close
Content-Length: 273
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
X-Cdn-Origin: SNPaaS
Accept-Ranges: bytes
Date: Thu, 06 Jul 2023 16:12:21 GMT
Via: 1.1 varnish
X-Served-By: cache-fra-eddf8230033-FRA
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1688659941.052221,VS0,VE102
alt-svc: h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400
**** CONTENT ****
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 Bad Request</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Bad Request</h1>
<h2>Your client has issued a malformed or illegal request.</h2>
<h2></h2>
</body></html>

HTTP WARNING: HTTP/1.1 400 Bad Request - 694 bytes in 0.125 second response time |time=0.124696s;;;0.000000;10.000000 size=694B;;;0
  1. www.snf.ch, gives 404 Not Found
$ check_http -I www.snf.ch -v
GET / HTTP/1.0
User-Agent: check_http/v2.2 (monitoring-plugins 2.2)
Connection: close


http://www.snf.ch:80/ is 274 characters
STATUS: HTTP/1.1 404 Not Found
**** HEADER ****
Date: Thu, 06 Jul 2023 16:15:26 GMT
Content-Type: text/html
Content-Length: 146
Connection: close
**** CONTENT ****
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

HTTP WARNING: HTTP/1.1 404 Not Found - 274 bytes in 0.013 second response time |time=0.013416s;;;0.000000;10.000000 size=274B;;;0

Version & other environment info:

$ icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.3-1)
$ sudo icinga2 feature list
Disabled features: compatlog elasticsearch gelf graphite icingadb influxdb influxdb2 livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker command debuglog ido-mysql mainlog notification
$ sudo icinga2 daemon -C
[2023-07-06 18:31:26 +0200] information/cli: Icinga application loader (version: r2.13.3-1)
[2023-07-06 18:31:26 +0200] information/cli: Loading configuration file(s).
[2023-07-06 18:31:26 +0200] information/ConfigItem: Committing config item(s).
[2023-07-06 18:31:26 +0200] information/ApiListener: My API identity: stivm0080.epfl.ch
[2023-07-06 18:31:26 +0200] warning/ApplyRule: Apply rule 'backup-downtime' (in /etc/icinga2/conf.d/downtimes.conf: 5:1-5:52) for type 'ScheduledDowntime' does not match anywhere!
[2023-07-06 18:31:26 +0200] warning/ApplyRule: Apply rule 'docker' (in /etc/icinga2/zones.d/master/services.conf: 50:1-50:22) for type 'Service' does not match anywhere!
[2023-07-06 18:31:26 +0200] warning/ApplyRule: Apply rule 'check_dump' (in /etc/icinga2/zones.d/master/services.conf: 176:1-176:26) for type 'Service' does not match anywhere!
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 IcingaApplication.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 2 HostGroups.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 20 Hosts.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 2 NotificationCommands.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 283 Notifications.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 2 FileLoggers.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 CheckerComponent.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 30 Zones.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 ExternalCommandListener.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 ApiListener.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 28 Endpoints.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 ApiUser.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 248 CheckCommands.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 1 NotificationComponent.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 9 Users.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 9 UserGroups.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 3 TimePeriods.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 263 Services.
[2023-07-06 18:31:26 +0200] information/ConfigItem: Instantiated 3 ServiceGroups.
[2023-07-06 18:31:26 +0200] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2023-07-06 18:31:26 +0200] information/cli: Finished validating the configuration file(s).

OS: Ubuntu 18.04


Both of the websites above work well with curl and wget on the same server.

Other websites, such as www.google.com work well also with check_http.

I have tried to mess around with all the various options (-f, -A, -S, …) but nothing seems to work. Does anybody have any ideas how to make this work?

Thanks!

You are trying to test via

-I, --IP-address=ADDRESS
    IP address or name (use numeric address if possible to bypass DNS lookup).

and this will fail for vhosts. You should use

-H, --hostname=ADDRESS
    Host name argument for servers using host headers (virtual host)

Thanks! Any idea why

$ check_http -I www.google.com 
HTTP OK: HTTP/1.0 200 OK - 19572 bytes in 0.157 second response time |time=0.156920s;;;0.000000;10.000000 size=19572B;;;0

works?

I’d assume it’s not configured via vhosts.