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! |
The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times. FREE! Go There Now!
|
|
|
|
WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
|
|
|
|
Join this webcast to see how IBM Data Studio Developer and pureQuery can take the pain out of Java data access. uApplications developed using both Java and SQL have become a common requirement. Database connectivity using Java Database Connectivity (JDBC) to create an application is a multi-step tedious process, and tooling that covers both SQL and Java has been unavailable, until now. IBM Data Studio introduces the pureQuery platform: a high-performance, Java data access platform focused on simplifying the tasks of developing, managing, and optimizing database applications and services. FREE! Go There Now!
|
|
|
|
This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. 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!
|
|
|
|
Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference, to hear how Enterprise Generation Language (EGL) eliminates the need for tedious and error-prone low level coding, so developers can focus on business requirements. EGL extends the Rational software development platform with a simplified programming language that enables developers who have little or no experience with Java, Web technologies or Service Oriented Architecture, to create enterprise-class applications and services quickly and easily. It also allows developers who may have little or no mainframe programming experience to quickly create traditional mainframe components. FREE! Go There Now!
|
|
|
|
In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information. 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!
|
|
|
|
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!
|
|
|
|
All FREE IBM® developerWorks Tools! |