Monitoring a website
I own nearly twenty websites; if those sites go down, my clients get mad. This recipe is a handy recipe to monitor a list of websites every five minutes and, if the site is unreachable, send out a text message.
We're going to use a simple key-value pair datastore system that will store the URL and the current status of the site in a file. If the site is down, we will send a notification to a list of users. Then, if the site is back up the next time the script runs, we will send another notification to the users to tell them that the site is up.
Getting ready
The complete source code for this recipe can be found in the Chapter6/Recipe8/
folder.
How to do it...
This recipe will build a simple website monitor that we will set up to check a list of sites every five minutes.
Download the Twilio Helper Library from https://github.com/twilio/twilio-php/zipball/master and unzip it.
Upload the
Services/
folder to your website.Upload
config.php
to your website and make sure the following...