Check a HTML body ignoring the http error code

Good morning everyone,

is there anybody knowing a good way to check the HTML body of a URL ignoring the http error code? I can’t find anything like that but would need it to monitor a service.

Best regards
Alicia

Hi,

you can use the standard check_http plugin for this. There are two parameters you need to define:

  • -e to define the expected status code e.g. 301
  • -s to search for a string inside the body
/usr/lib/nagios/plugins/check_http -H myhost.local -e 301 -s nginx

This will expect a 301 status code and the string nginx inside the body. If any of this is not present the status will be critical. It is also possible to define multiple status codes with a comma seperated list.

https://www.monitoring-plugins.org/doc/man/check_http.html

The check_http plugin is part of the Icinga Template Library.

https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#http

The custom variables you need to define are http_expect and http_string.

Best regards
Michael

1 Like

Thank you :bouquet:

I didn’t understand the -e parameter correct. Now it works!

1 Like