Replacing check_http with plain curl for HTTP/2 and Keep-Cookie-On-Redirect support

Hi everyone,

I just want to share my quick solution for checking HTTP sites (with perfdata) for proper HTTP/2 support and for sites that redirect with required cookies (e.g. PHPSESSID) using a Classical active and passive Monitoring check with the curl command line tool:

HTTP/2:

Command line:

/usr/bin/curl -s -o /dev/null -w 'HTTP/%{http_version} %{http_code} - %{size_download} bytes in %{time_total} second response time|time=%{time_total}s size=%{size_download}B time_connect=%{time_connect}s time_firstbyte=%{time_starttransfer}s\n' -k --http2-prior-knowledge --resolve $_HOSTFQDN$:443:$HOSTADDRESS$ https://$_HOSTFQDN$

(I have defined FQDN as a Custom Host Attribute so I can use this service definition as a template.)

HTTP/1.1 following redirects while keeping cookies:

Command line:

/usr/bin/curl -s -o /dev/null -w 'HTTP/%{http_version} %{http_code} - %{size_download} bytes in %{time_total} second response time|time=%{time_total}s size=%{size_download}B time_connect=%{time_connect}s time_firstbyte=%{time_starttransfer}s\n' -L -c- --http1.1 --resolve <FQDN>:443:$HOSTADDRESS$ https://<FQDN>

(The magic lies in the -c- switch).

Hope that helps someone with similar problems or maybe someone has an even more elegant solution :wink:

Regards,
Moritz

PS: Old thread on that issue: [Check_mk (english)] Check_http cookie support