How to monitor server for error establishing a database connection

I know there are tools like pingdom.com and uptimerobot.com that will monitor your site and let you know if they’re down, but I find that my WordPress site is experiencing the dreaded “error establishing a database connection” more often than desired, and I’d like to get some sort of notification when that happens (but not in the form of a user complaint!). Pingdom and Uptimerobot do not consider that an error, and thus do not push any notifications.

Are there any simple tools or methods that will monitor my site for that specific problem (and perhaps other problems?) that may not be caught otherwise.

[Edit]
1. I’m referring specifically to the the well-known WordPress error that often occurs due to various DB connectivity reasons. When the error occurs, visiting the site returns the default white page with text shown below.

  1. For the purposes of this question, I’m not interested in why it occurs or how to fix it, but instead, I’d simply like to figure out how to automatically monitor it and get notified. Thanks.

enter image description here

5 Answers
5

You can actually use Pingdom to check for this kind of error, rather than a straight forward check for a response from the server you can configure the check to look for a particular string on the page. For instance, if your page has some kind of consistent bit of text on the homepage then you can look for that.

This Pingdom post has some info about checking for strings:

Make the most of your HTTP check: best practice for optional settings

You can also check that it doesn’t have particular string, so you should be able to make it flag it as down if it shows the text “Error establishing a database connection”.

Leave a Comment