Chkdomains script
<?php
/* Copyright 10/30/2006 freelock computing
- chkdomains.php
- basic site monitoring script
- sends an email when status is different than previous running of the script
-
-
- installation instructions
- create a /var/www/conf directory to store this
- /var/www/conf/satus contains the cache result
- this must be writable by the user running the job
- add a URL to the $site array for each site to check
- set $mailto to appropriate email addresses, comma seporated
- schedual the cron job (php command line package required php_cli)
- The status file needs to be writiable by the script ( a user accont
- that runs the script)
- on your server that is to be checked, create a textfile called "FILENAME" with your success string, this must match exactly, newlines and whitespace matter.
-
-
- Testing instructions
- delete or change the contents of the domain_uptime.txt
- run the script
- check the contents of the new domain_uptime.txt file
- check your email
-
-
- files,
- on each server, uptime.txt
- on monitoring system
- /var/www/conf/status/domain_uptime.txt conists of 1's and 0's seporated by newlines, this is rewritten every run. 1's represent server being up, 0's represent server being down.
- /
$site[] = "http://yoursite1.com/";
$site[] = "http://yoursite2.org/";
$site[] = "http://yoursite3.net/";
$mailto = "sys-admin@yourdomain.com,optionaladditional@email.com";
define('FILENAME', "uptime.txt");
define('SUCCESS', "success");
define('STATUS_FILE', '/var/www/conf/status/domain_uptime.txt'); #
$out = ;
for ($i=0; $i
{
$filename = $site[$i] . FILENAME;
if ($fp=@fopen($filename,'r')){
$err = socket_get_status($fp);
if ($err['timed_out']) {
$txt = "$filename timed out\n";
$status[$i]= 0;
}
else
{
$text = trim(fread($fp, 2048));
$txt = $filename. ': ' . $text . '(' . ($text
















