Revision: 24764
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 10, 2010 15:41 by vagrantradio
Initial Code
<?php /* Author: Jason Pant Url: http://www.vagrantradio.com */ $uptime = @exec('uptime'); preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/",$uptime,$avgs); $uptime = explode(' up ', $uptime); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0].', '.$uptime[1]; $start=mktime(0, 0, 0, 1, 1, date("Y"), 0); $end=mktime(0, 0, 0, date("m"), date("j"), date("y"), 0); $diff=$end-$start; $days=$diff/86400; $percentage=($uptime/$days) * 100; $count = number_format($percentage, 0); $load=$avgs[1].",".$avgs[2].",".$avgs[3].""; $server = getenv('SERVER_NAME'); $port = getenv('SERVER_PORT'); $software = getenv('SERVER_SOFTWARE'); $protocol = getenv('SERVER_PROTOCOL'); $interface = getenv('GATEWAY_INTERFACE'); function GetServerStatus($server, $port) { $status = array("OFFLINE", "ONLINE"); $fp = @fsockopen($server, $port, $errno, $errstr, 2); if (!$fp) { return $status[0]; } else { return $status[1];} } $status = GetServerStatus($server,$port) ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Server Statistics For <?php echo $server ?></title> <style type="text/css"> td{ border-style: solid; border-width: 1px; color: #000000; } table{ border-style: solid; border-width: 1px; color: #000000; } tr{ border-style: solid; border-width: 1px; color: #000000; } </style> </head> <body> <table width="100%" cellspacing="0" cellpadding="0" style="border: 1 solid #000000" border="1"> <tr> <td width="50%" bgcolor="#3973AC" style="border: 1 solid #000000"><font color="#FFFFFF">Server Details</font></td> <td width="50%" bgcolor="#3973AC" style="border: 1 solid #000000"><font color="#FFFFFF">Server Statistics</font></td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"> </td> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"> </td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Name:</b> <?php echo $server ?> </td> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Uptime</b> (days): <?php echo $uptime ?></td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Port:</b> <?php echo $port ?></td> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Uptime </b> (%): <?php echo $count ?>%</td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Software: </b> <?php echo $software ?></td> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Load:</b> <?php echo $load ?> </td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Protocol:</b> <?php echo $protocol ?></td> <td width="50%" bgcolor="#7CA8D3" rowspan="3" style="border: 1 solid #000000"><b>Status:</b> <?php echo $status ?></td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Gateway:</b> <?php echo $interface ?></td> </tr> <tr> <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"> </td> </tr> </table> </body> </html>
Initial URL
Initial Description
I'm sure this could be improved, but it works. Checks uptime, current status and others.
Initial Title
Php Server Stats
Initial Tags
Initial Language
PHP