Public page with status of server load

yoseman

Member
Jun 10, 2007
9
0
151
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.
 
Last edited:

zamrg

Active Member
Oct 17, 2010
34
0
56
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.
 

kjg

Well-Known Member
Mar 2, 2004
180
8
168
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