Ask: Wordpress site error messages alert monitoring (monit / other tools linux based server)

78 Views Asked by At

need some advice to monitoring wordpress site error messages hosted in linux (open source tools & free) error messages like these:

  • "Error establishing database connection"
  • "Error establishing a Redis connection"
  • "This site can't be reached"
  • "Briefly unavailable for scheduled maintenance".
  • "Page Not Found"
  • "There has been a critical error on your website"

I had setup monit to monitoring process service regarding DB, webserver, redis, and php-fpm sometimes above error occurred due the wordpress plugins / files error not because services - is there anyway i tried to monitoring the site with below rules but somehow i can't make it work

check host example with address example.com
  if failed (url https://example.com and content == 'Error establishing a Redis connection')
then alert
# below also not working
check host example with address example.com
  if failed
    url example.com
    port 80/443
    proto http/https
    content = ""
#tried with content = "" 

I believe the check host rule for content need to add url as well (please cmiiw) and somehow i dont know if the test rule failed due this error as an alert notif i got is

failed protocol http/https test hope you can advice me about this & feel free to suggest different approach for other ways / tools for my purpose above

Thank you!

1

There are 1 best solutions below

3
lutzmad On

Monit does not listen on an output stream, but you can monitor the wordpress/web server log file.

Or you can send requests to an application and check the response/content, see https://mmonit.com/monit/documentation/monit.html#HTTP

Send an alert if you get an unexpected response, for http and https also.

if failed port 80 protocol http and request "ok"
   with content = "awaited text" then alert
if failed port 443 protocol https and request "ok"
   with content = "awaited text" then alert

Send an alert if you get an expected response.

if succeeded port 80 protocol http and request "error" 
   with content = "error text" then alert

A suggestion based on your sample.

check host example with address example.com
  if succeeded port 80 protocol http and request "something"
     with content == "Error establishing a Redis connection"
     then alert

An alert will send, if you receive the expected error text for the request.

Based on your sample the following host check will send an alert all the time one of the expected messages are in the response.

check host example with address example.com
  if succeeded port 80 protocol http content == "Error establishing database connection|Error establishing a Redis connection|This site can't be reached|Briefly unavailable for scheduled maintenance|Page Not Found|There has been a critical error on your website"
     with timeout 20 seconds then alert
  if succeeded port 443 protocol https content == "Error establishing database connection|Error establishing a Redis connection|This site can't be reached|Briefly unavailable for scheduled maintenance|Page Not Found|There has been a critical error on your website"
     with timeout 20 seconds then alert

Each test try to connect to port 80 and 443 with the proper protocol, send a request and check the content of the response. If the response match to the content an alert will send.

And based on a Wordpress example the status is handled also.

check host wordpress with address wordpress.org
  if succeeded port 443 protocol https
     and request "/brokenlink.php" with status > 400 
     and content == "Oops! That page can’t be found."
     with timeout 20 seconds
     then alert

The status send by the broken link sample is 404.