In fact, if you have PHP on your system, it’s exactly this amount of code:
<?php
// monitor a site, write errors to a log....
// copyright (c) 2005 D.Pankhurst (BigBizBlog.com)
// free to use - just please keep copyright in
$url="www.YOURSITE.com"; // site to monitor
$res="result.txt"; // your results file
$openURL=false;
$fp = @fsockopen ($url,80,$errno,$errstr,8);
if($fp)
{
$openURL=true;
fclose($fp);
}
$outString =date('YMd-H:i:s')." - ".$url.($openURL?": OK":": ERR")."\n";
if ( !$openURL )
{
$fileName=dirname($_SERVER['SCRIPT_FILENAME']) .'/'.$res;
if ( $fp = @fopen($fileName,'a+') ) // success?
{
fputs($fp,$outString);
fclose($fp);
}
}
echo $outString;
?>
What it does is reside on another site (obviously – it won’t do much good checking its own site), and do a test as often as needed. If the website call fails, then the program writes a record of the failure to disk, allowing you to easily check it day in, day out.
To use, just:
- Copy the code to a file, making sure you rename the website ($url) to yours, and the text file ($res) to whatever suits you.
- Upload the code as anything you want – check.php, for instance.
- Upload an empty text file, called result.txt (or whatever you set $res to) to the same directory.
- Change the text file’s permission to 777.
- Add a CRONTAB entry for this program that will allow it to be called regularly – here’s an example:
* * * * * wget -q -O /dev/null http://www.YOURSITE.com/check.php
You can set to run this at any interval that’s suitable, but I find once a minute works well.
Now, whenever your (other) site is down, the call fails, and an entry is written to disk. From your browser, you can look at the text file (bookmark it if you want), and know how your site is doing.
And now for something off-topic: if you found this easy to set up, then you’ll have no trouble with ActiveLinker, my product to give you your own ‘tinyurl’ service, and protect affiliate links. Buy it today.







this idea is very good, however, what if i have 5-10 sites ?
i use —– which sends me an email every time my site is down …. maybe you can think on this too: to send an email every time the site is down ….
For multiple sites, you could either edit the code to check each site, or run multiple version of the code. And for email, this could be done as well. But for a free alternative to paid services, this code as it is can make monitoring a single site straightforward.