This script generates a table of values which contain the following data:
Average server load
Server Uptime (In days)
Server Uptime (as percentage of the year so far)
Server Name
Server Port
Server Software
Server Gateway
This is displayed on the browser for either your personal use or for public display.
You can find more scripts on my site
here By : Andrew
<?php
/*
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='<html>
<head>
<title>Server Statistics For '.getenv('SERVER_NAME').'</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> '.getenv('SERVER_NAME').'
</td>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Uptime</b>
(days): '.$uptime.'</td>
</tr>
<tr>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Port:</b>
'.getenv('SERVER_PORT').'</td>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Uptime
</b>
(%): '.$percentage.'%</td>
</tr>
<tr>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Software:
</b>
'.getenv('SERVER_SOFTWARE').'</td>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Load:</b> '.$load.' </td>
</tr>
<tr>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Protocol:</b> '.getenv('SERVER_PROTOCOL').'</td>
<td width="50%" bgcolor="#7CA8D3" rowspan="3" style="border: 1 solid #000000"><small>Server statistics provided by <a href="http://www.kendocreations.co.uk">ServerStat</a> 1.0</small></td>
</tr>
<tr>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Gateway:</b> '.getenv('GATEWAY_INTERFACE').'</td>
</tr>
<tr>
<td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"> </td>
</tr>
</table>
<p align="center"><small>Created By: Andrew Walsh</small></p>
</body>
</html>';
echo $page;
?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.
More Counters Code Articles More By Codewalkers
Please enable JavaScript to view the comments powered by Disqus. blog comments powered by