cancel
Showing results for 
Search instead for 
Did you mean: 

Server Load and Uptime

N/A

Server Load and Uptime


<?php
$loadavg_array = explode(" ", exec("cat /proc/loadavg"));
$loadavg = $loadavg_array[2];
print("Server load: " . $loadavg . "%");
?>


I use the above for gettin the server load onto a module on my site - on another host

Is it possible to have "/proc/loadavg" installed on the cgi platform here?
I'm not sure if its availble for FreeBSD or not? but i dont link useing perl - which currently is the only way i can do it.


Scott
1 REPLY
csogilvie
Grafter
Posts: 5,852
Registered: 04-04-2007

Server Load and Uptime

You don't need to use perl... you can parse the output of "uptime" to get the load average.

<?
exec("/usr/bin/uptime", $ret);
echo $ret[0];
?>