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
hereBy : 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
developerWorks - FREE Tools! |
As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
|
|
|
|
CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications. FREE! Go There Now!
|
|
|
|
This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
|
|
|
|
Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase. FREE! Go There Now!
|
|
|
|
Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
|
|
|
|
Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly. FREE! Go There Now!
|
|
|
|
The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |