Forum
Notifications
Clear all
Topic starter
Here is the PHP function to show/display your Linux average server load with PHP.
With this method, you won't need to access your server via WHM, SSH, or any other server tools/panels if you just want to see your average server loads.
<?php
function get_avg_svr_lod($win = 0) {
$opr_sys = strtolower(PHP_OS);
$lod = '';
if(strpos($opr_sys, "win") === false) {
if(file_exists("/proc/loadavg")) {
$lod = file_get_contents("/proc/loadavg");
$lod = explode(' ', $lod);
}elseif(function_exists("shell_exec"))
$lod = explode(' ', 'uptime');
}
return $lod;
}
$res = get_avg_svr_lod();
?>
Example of usage:
<font style="font-family:'courier new';font-size:12px">
Past 1 Minute : <?php echo $res[0]; ?><br/>
Past 5 Minutes : <?php echo $res[1]; ?><br/>
Past 15 Minutes : <?php echo $res[2]; ?>
</font>
Posted : 10/02/2012 7:41 am