- edited description
Indicate regular expression content mismatch in the alert message when checking hosts
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)
-
reporter -
reporter - edited description
-
repo owner - changed status to closed
there are two errors in your case: one for IPv6, one for IPv4. Monit tries last-man-standing if no IP protocol is specified, hence it tries IPv4 first, followed by IPv6 ... both failed, the reported error comes from the last attempt.
If you want to reduce attempts to IPv4 only, set the test accordingly: https://mmonit.com/monit/documentation/monit.html#CONNECTION-TESTS
-
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. -
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
-
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!
- Log in to comment