Add to Favorites

Server Monitoring Tools (php)

I've been looking for a decent (simple) server monitoring tool that I could install to view at a snapshot glance what our servers are doing.

I found several and thought I'd share a few:

1. Iguana Server Monitor (open source)

Install this simple php script on the box you want to view stats for and you're good to go. Really it's that simple. Just upload a php script to your web directory, browse to that page and you can see in an instant all the specs of your server, processes, etc.

2. http validation script

This script is extremely simple. All written in php - you just adjust some variables and get emailed when your site is down. It can be posted on any server and will look at your website at the intervals you set. Furthermore, you can check to see if text is missing from your page so you aren't just testing for a page, rather for "your" page by validating text that should be there. A simple http validation won't always indicate that the web server is down because you may see a "page cannot be found" which is still bad.

Here's the code I found on some forum somewhere. There were several samples and this edited version seems to work well. Will try to find it again to give credit.

[php]
$timeout = 1;
$checking_word = "test- or any unique text on your web page";
$url= "yourdomain.com";
$pFile = fopen("status.log","a");
$email_address = "youremail@yourdomain.com";

$headers = "From: " . "Site Check" ." <" . "youremail@yourdomain.com" . ">\r\n";
$headers .= "Reply-To: " . "Site Check" ." <" . "youremail@yourdomain.com" . ">\r\n";

if( !$fp = @fsockopen( $url, 80, $errno, $errstr, $timeout ) ) {
echo("Couldn't connect to the server.");
// do some recovery action here.
fwrite($pFile,strftime("%A, %c").": ".$url . " is down.\n");
mail($email_address,"'$url' is down","'$url' is down.",$headers);
}
else {
$page = implode( '', file( 'http://'.$url ) );
if( !strstr( $page, $checking_word ) ) {
// probably the webserver is not serving the page
// do some recovery action here.
fwrite($pFile,strftime("%A, %c").": ".$url . " is down.\n");
mail($email_address,"'$url' is down","'$url' is down.",$headers);
}
}
fclose($pFile);

?>

[/php]

3. Status Monitor

This is my favorite. You plugin the IPs of the servers you need to monitor. Create the cron jobs to have emails sent when services are down. You can add your own services to monitor by just inserting the ports to check. Many other little features and you can see all the servers from one screen shot. Very simple to install and works like a charm.

Nice little admin tool as well that let's you manage your sites. Fully customizable open source code so you can add all the features you can dream of using php.

Here's a little screen shot.

server monitoring scripts php

Thanks to the folks at sillyDNS for a fine script.

Comments

Be the first to leave a comment on this post.

Leave a comment

To leave a comment, please log in / sign up