Counters Code
  Home arrow Counters Code arrow Server Uptime Statistics
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COUNTERS CODE

Server Uptime Statistics
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2004-08-24

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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">&nbsp;</td>
    <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000">&nbsp;</td>
    </tr>
    <tr>
    <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Name:</b>&nbsp;'.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>&nbsp; '.$load.' </td>
    </tr>
    <tr>
    <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000"><b>Protocol:</b>&nbsp; '.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>&nbsp;'.getenv('GATEWAY_INTERFACE').'</td>
    </tr>
    <tr>
    <td width="50%" bgcolor="#7CA8D3" style="border: 1 solid #000000">&nbsp;</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

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM DB2 Deep Compression ROI Tool

    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!


    NEW! Discovering the value of WebSphere Process Server

    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!


    NEW! Harnessing the power of SQL and Java for high performance data access

    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!


    NEW! Maintaining QoS and Process Integrity in an SOA Environment

    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!


    NEW! Rational Asset Manager eKit

    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!


    NEW! Trial download: IBM Lotus Forms V3.0

    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!


    NEW! Using Rational Business Developer to enhance your developer productivity

    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!


    NEW! Webcast: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    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!


    NEW! Webcast: IBM Rational Build Forge - Beyond the Build

    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!


    NEW! Webcast: Striking the right balance between manual and automated testing

    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!

    COUNTERS CODE ARTICLES

    - TG Who's Online
    - Text Based Counter that formats output
    - Counter & visitor statistics
    - Server Uptime Statistics
    - Chris Dingman's Hit Tracker Script
    - Graph Maker Function
    - Simple userOnline class
    - Adv. Log file generator
    - Logwriter
    - time_left()
    - Basic Statistics
    - Easy Counter
    - countCodeLines
    - MySQL Counter
    - bandwidthmeter





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek