ezservermonitor-web/libs/load_average.php

25 lines
432 B
PHP
Raw Normal View History

2014-06-18 04:11:11 -04:00
<?php
if (!($load_tmp = shell_exec('/bin/cat /proc/loadavg | /usr/bin/awk \'{print $1","$2","$3}\'')))
{
$load = array(0, 0, 0);
}
else
{
$load_exp = explode(',', $load_tmp);
$load = array_map(
function ($value) {
$v = (int)($value * 100);
if ($v > 100)
$v = 100;
return $v;
},
$load_exp
);
}
$datas = $load;
echo json_encode($datas);