Simple PHP Web uptime script

by Ruchira on December 5, 2010

Having 100s days of server uptime with your shiny linux box? Wanna showoff like I want to do? icon razz Simple PHP Web uptime script Or want to monitor server uptime without SSHing to server? There is nice way to showoff your uptime in simple PHP script which requires nothing fancy changes on your linux box. Ill will display system time load averages and uptime in simple layout.

uptime1 Simple PHP Web uptime script

You just want to do is create a .php file in your notepad and enter this syntax on notepad

<code> &lt;?PHP system('uptime'); ?&gt;

When saving dont forget to choose "all files" and then name it whatever you want end in .php as file name.
ex- uptime.php and then move the saved file to your server path. ex- www.domain.com/uptime.php

If you are too lazt to create the php file on notepad just download the uptime.php file here and unrar it and put in to your web site directory.
www.ruchirablog.com/tools/uptime.rar

Thats it.

See it live on ruchirablog.com

http://www.ruchirablog.com/uptime.php

I'm Ruchira Sahan and all posts on this blog are completely my thoughts and writings. I love DIY and Technology. So feel free to contact me for anything about this blog and don't forget to add a comment if this blog helped you! Thanks
 Simple PHP Web uptime script
Ruchira
View all posts by Ruchira

Last 5 posts by Ruchira

  • Ken

    I was looking for something like this for a CMS/web site I’m building. After I spent a couple of days obsessively writing PHP, a language I was not yet much good at, I churned this out, and improved m PHP coding skills tremendously! It’s a bit verbose in its capabilities, but it will return just about any output you need from ‘uptime’.

    <?php
    /*
    SCRIPT NAME: PHP System Uptime
    FILE NAME: phpuptime.php
    AUTHOR: Ken (E-MAIL: erezerwebservices@gmail.com, URL: http://www.erezer.net)
    PURPOSE: Processes the output of the Linux 'uptime' command to render it easier to use in a PHP script.
    USE:
    uptime() - returns the system uptime
    uptime(uptime) - same effect as uptime()
    uptime(users) - returns the number of users currently logged in the format of "X users"
    uptime(numeric) - returns only the numerical value number of users currently logged in
    uptime(load) - return the system load for the last one, five and fifteen minutes
    uptime(load_one_min) - return the system load for the last minute
    uptime(load_five_min) - return the system load for the last five minutes
    uptime(load_fifteen_min) - return the system load for the last fifteen minutes

    OTHER INFO: Use require() to include this script in a PHP document and to make direct calls to the uptime() function.
    You must supply the correct path to phpuptime.php, as per your directory structure. It is advised that
    you use require(), and not include(), as require() is considered to be a more safe function than include().

    Example:
    */
    ?>

    <?php
    // This is an example of how to use the uptime() function. It demonstrates several methods of use for this function.

    $br = "”;

    print phpuptime() . $br;
    print phpuptime(uptime) . $br;
    print phpuptime(users) . $br;
    print phpuptime(users_numeric) . $br;
    print phpuptime(load) . $br;
    print phpuptime(load_five_min) . $br;
    print phpuptime(load_one_min) . $br;
    print phpuptime(load_fifteen_min) . $br;
    ?>

  • Ken

    Some of the code was cut out from my last post. I’m not sure if it is because it is awaiting moderation, if the blogging software chopped it out, or if it was my own user error. Either way, I apologize if it does not post once approved :)

  • Daniel

    how would this be possible to work as a widget ?

    im using wordpressblog http://allblog.eu note the content is in danish language i like your script but culd really use it as widget on my blog !

    my personal link site http://sourcebook.eu

    • http://www.ruchirablog.com Ruchira

      I see you have achieved this :)

Previous post:

Next post: