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! |
Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration. FREE! Go There Now!
|
|
|
|
Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
|
|
|
|
In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications. FREE! Go There Now!
|
|
|
|
Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization. FREE! Go There Now!
|
|
|
|
Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
|
|
|
|
As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
|
|
|
|
Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right." FREE! Go There Now!
|
|
|
|
Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |