Indicate regular expression content mismatch in the alert message when checking hosts

Issue #949 closed
PT created an issue

If there is a content regexp mismatch, the alert says “Address not available” (and the email says “Connection failed” which isn’t true because the connection did not fail). Reproducible with v 5.27.1.

Config:

check host example.com with address example.com
   if failed 
        port 80 protocol http
        and request "/" with content != '<!doctype html>.*'
        with timeout 10 seconds
   then alert

This will result in these verbose log messages

Socket test failed for [93.184.216.34]:80 -- HTTP error: Regular expression matches
Socket test failed for [2606:2800:220:1:248:1893:25c8:1946]:80 -- Address not available
'example.com' failed protocol test [HTTP] at [example.com]:80/ [TCP/IP] -- Address not available
Sending Connection failed notification to user@example.com

Changing the comparison to = will result in no alert.

Comments (6)

  1. PT reporter

    Thanks a ton for such a quick response! Please accept my apologies for not RTFMing.

    Do I understand correctly that if I don’t want a ping test and only want an HTTP test for IPv4 only, I have to specify the IPv4 address in the with address clause? I don’t suppose I could make it work with Cloudflare’s Flexible SSL though, and CloudFlare doesn’t allow to disable AAAA records. I guess I could try building from source with --without-ipv6 flag set.

  2. Tildeslash repo owner

    You don’t need to set the specific address, just set the IP protocol version, for example:

    if failed host example.com port 80 ipv4 protocol http then alert
    

  3. PT reporter

    Tildeslash, you are the best! Thank you so much for your assistance and for this amazing piece of software.

    Yesterday I tried sticking that ipv4 directive in various places but it would always complain of a syntax error. I guess should have tried harder.

    Thanks again!

  4. Log in to comment