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!


    NEW! A Layered approach to delivering security-rich Web applications

    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!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    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!


    NEW! Download IBM Data Studio V1.1

    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!


    NEW! Evaluate Rational Host Access Transformation Services (HATS) Toolkit V7.1

    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!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    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!


    NEW! IBM Rational ClearCase Innovator's Series

    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!


    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! Rational Build Forge Express eKit

    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!


    NEW! Try the IBM SOA Sandbox for Process

    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!


    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!



    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 3 Hosted by Hostway
    Stay green...Green IT