Nagios is pretty much the industry standard, but it's a behemoth and you can easily lose a day just configuring it.
But actually, if you can run PHP (on command line) then a script like this will work:
PHP Code:
<?php
$url = 'http://www.example.com/'; // This can be a full URL if you like
$word = 'hello'; // Word to search for
// If we have a URL passed on the command line then use it
if (count($argc) > 1) {
$url = $argv[1];
}
// Email variables
$mailTo = 'your@email.com';
$mailSubject = 'Website Monitoring for ' . $url;
$mailMessage = "Epic fail\n\nThe site is not working properly!";
// Grab the page
$page = file_get_contents(urlencode($url));
// Search for the word in the page
if (!stristr($page, $word)) {
if (!mail($mailTo, $mailSubject, $mailMessage)) {
echo "Could not send the email, make sure Postfix or Sendmail is installed and running!\n";
exit(1);
}
} else {
exit(0); // Do nothing and exit with a Posix success code
}
Save the above as whatever.php and run it like:
Code:
php whatever.php '<URL>'
The URL is optional and defaults to whatever is set inside the script.
You can set this via CRON, Google it or use whatever control panel you have on your webhost if applicable.
If you need a version modified that you can use on a webpage, let me know.