The source of server_mon.php (click to demo the file) viewed 8389 times.

If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.


<?php
/////////////////////////////////////////////////////
// Server Monitor v1.0 - sebflipper Copyright 2004 //
//         http://www.sebflipper.com/               //
//                                                 //
//      This is a simple script to monitor a       //
//      list of ports from a list of domains       //
                                                   //
//     Don't forget to download green.gif and      //
//        red.gif for the status icons             //
/////////////////////////////////////////////////////

// Config Area
// Enter a list of domain names you want to monitor
$domains = array("sebflipper.com""multi-forums.net""woollydogpaintings.com""pdjkeelan.co.uk""ffhut.co.uk");
// Enter a list of ports you wish to monitor (80 = HTTP, 21 = FTP, 25 = SMTP, 3306 = MySQL)
$ports = array("80""21""25""3306");

// How often the page should refresh
$page_refresh "300"// in seconds

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="REFRESH" content="<?php echo $page_refresh?>">
<title>Server Monitor</title>
<style type="text/css">
<!--
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: small;
}
-->
</style>
</head>
</body>
<?php
// PHP Script
// Turn off all error reporting
// Removes errors like fsockopen failed if the script couldn't connect to the port
error_reporting(0);

// Main moniting function
function server_monitor($domain,$port) {
    
$fp fsockopen ($domain$port$errno$errstr10);
    if (!
$fp) { 
        return 
"<img src=red.gif alt='Status: Down, Domain: $domain, Port: $port'>\n"
    } else { 
        return 
"<img src=green.gif alt='Status: Up, Domain: $domain, Port: $port'>\n"
    }
    
fclose($fp);
}

// Foreach array
foreach ($domains as $domain_value) {
    echo 
"<b>Checking $domain_value...</b><br>\n";
    echo 
"<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
    foreach (
$ports as $port_value) {
        echo 
"<td>Port: $port_value</td>";
   }
   echo 
"</tr>\n<tr>\n";
    foreach (
$ports as $port_value) {
        echo 
"<td><center>"server_monitor($domain_value,$port_value) . "</center></td>\n";
   }
   echo 
"</tr></table><br><br>\n";
}

?>
Don't forget to download <img src=green.gif> and <img src=red.gif> and place them in the same folder as this script
</body>
</html>

If you want to have a look at the source code, chose a file from this list:

ip.txt
(Demo Script)
userdetails.php
(Demo Script)
perl_smtp_email.php
(Demo Script)
server_mon.php
(Demo Script)
floor_time.php
(Demo Script)
url_verify.php
(Demo Script)
birthday.php
(Demo Script)
md5_password.php
(Demo Script)
email.php
(Demo Script)
char_limit.php
(Demo Script)
time.php
(Demo Script)
htpasswd_maker.php
(Demo Script)
title_case.php
(Demo Script)
password.php
(Demo Script)
phpself.php
(Demo Script)
smarty.php
(Demo Script)
phpinfo.php
(Demo Script)
ip_monitor.php
(Demo Script)
html.php
(Demo Script)
pad_test.php
(Demo Script)
mysql_backup.php
(Demo Script)
cookies.php
(Demo Script)
unix_time.php
(Demo Script)
convert_link.php
(Demo Script)

To colour code your own PHP paste it here: