Voting

: max(seven, seven)?
(Example: nine)

The Note You're Voting On

vladvarna at gmail dot com
12 years ago
You can emulate loadavg using this. Can also be used to get iowait

<?php
function ProcStats()
{
$fp=fopen("/proc/stat","r");
if(
false===$fp)
return
false;
$a=explode(' ',fgets($fp));
array_shift($a); //get rid of 'cpu'
while(!$a[0])
array_shift($a); //get rid of ' '
var_dump($a);
fclose($fp);
return
$a;
}

$a=ProcStats();
sleep(5);
$b=ProcStats();


$total=array_sum($b)-array_sum($a);

$loadavg = round(100* (($b[0]+$b[1]+$b[2]) - ($a[0]+$a[1]+$a[2])) / $total, 2); // user+nice+system
$iowait= round(100* ($b[4] - $a[4])/$total,2);

?>

<< Back to user notes page

To Top