The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Public page with status of server load

Discussion in 'General Discussion' started by yoseman, Oct 29, 2010.

  1. yoseman

    yoseman Member

    Joined:
    Jun 10, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I want to put a server load status on a public page.

    Does anyone know the steps to do this. It's basically an html page that obtain from server the load.

    Something like service status:

    Server Load 0.00 (4 cpus)
    Memory Used 14.5 %



    Thank you.
     
    #1 yoseman, Oct 29, 2010
    Last edited: Oct 29, 2010
  2. luxhosting

    luxhosting Member

    Joined:
    Sep 3, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    same search here ...
    Thanks
     
  3. zamrg

    zamrg Active Member

    Joined:
    Oct 17, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    A simple free solution would be to write a quick bash script, stick it on a cron job, and have it generate a html page inside your webroot, or even ftp it to your www. website if it's hosted offsite.

    If you don't mind paying a bit for a license, Server Load and Performance Notification | Status2K is looks like a really good product.
     
  4. kjg

    kjg Well-Known Member

    Joined:
    Mar 2, 2004
    Messages:
    147
    Likes Received:
    0
    Trophy Points:
    16
    The server load can easliy be done using the API.

    Get the cpanel API class at:
    http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.6.tar.gz

    (Read about it on this thread:
    http://forums.cpanel.net/f42/xml-api-php-class-version-1-0-a-136449.html )

    Unpack and upload it on the server where you want to display the load

    I have made a script that will show the load below.

    Just create a file called whateveryouwant.php, paste the code below (add ip and pass or hash) and upload it to the same directory as you have uploaded the xmlapi.php to.


    <?php
    include("xmlapi.php");

    ############### ENTER YOUR SERVER IP HERE
    # Enter your server IP here
    $ip = "";

    ############# ENTER PASSWORD OR HASH HERE
    # Enter your root password between the " and " if you want to use password
    $root_pass = "";

    # If you want to use hash instead: In WHM go to Cluster/Remote Access - Setup Remote Access Key and copy the entire key (all lines) and paste it between " and " below.
    $root_hash = "";


    if ( $ip && ip2long($ip) ) { # checking that IP is OK
    $xmlapi = new xmlapi($ip);
    if ($root_pass || $root_hash) { # has to be one of theese
    if ($root_pass) {
    $xmlapi->password_auth("root",$root_pass);
    }
    else if ($root_hash) {
    $xmlapi->hash_auth("root",$root_hash);
    }
    $xmlapi->set_output("array");
    $xmlapi->set_debug(0);

    $result = $xmlapi->loadavg();
    echo "Average load <br />last minute: " . $result['one'] . "<br />last 5 minutes: " . $result['five'] . "<br />last 15 minutes: " . $result['fifteen'] . "<br />";
    }
    else {
    echo "You have to set password or hash";
    }
    }
    else {
    echo "You have to set a correct IP";
    }

    ?>

    If you have checked the "Require security tokens for all interfaces" under WHM - Server Configuration - Tweak Settings . Security you might run into problems with the api


    // kjg
     
  5. yoseman

    yoseman Member

    Joined:
    Jun 10, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    Thank you very much, That's excellent.

    Thx
     
Loading...

Share This Page