Sunday, February 04, 2007

Codewalkers Tutorials

From strings to this on codewalkers.

/*
Author: Andrew Walsh
Username: Andrew
Email: andrew@walshdev.com
Url: http://walshdev.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;
$load=$avgs[1].",".$avgs[2].",".$avgs[3]."";
$page='

Server Statistics For '.getenv('SERVER_NAME').'




































Server
Details
Server
Statistics
   
Name: '.getenv('SERVER_NAME').'
Uptime
(days): '.$uptime.'
Port:
'.getenv('SERVER_PORT').'
Uptime

(%): '.$percentage.'%
Software:

'.getenv('SERVER_SOFTWARE').'
Load:  '.$load.'
Protocol:  '.getenv('SERVER_PROTOCOL').' Server statistics provided by ServerStat 1.0
Gateway: '.getenv('GATEWAY_INTERFACE').'
 

Created By: Andrew Walsh




';
echo $page;
?>

No comments: