mirror of
https://github.com/ShaYmez/ezservermonitor-web.git
synced 2024-11-25 17:28:55 -05:00
3ed4c1d633
Load Average and CPU : fix on recovery the number of CPU cores Last login : the datas are retrieved differently
30 lines
565 B
PHP
30 lines
565 B
PHP
<?php
|
|
require 'Utils/Misc.class.php';
|
|
|
|
if (!($load_tmp = shell_exec('cat /proc/loadavg | awk \'{print $1","$2","$3}\'')))
|
|
{
|
|
$load = array(0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
// Number of cores
|
|
$cores = Misc::getCpuCoresNumber();
|
|
|
|
$load_exp = explode(',', $load_tmp);
|
|
|
|
$load = array_map(
|
|
function ($value, $cores) {
|
|
$v = (int)($value * 100 / $cores);
|
|
if ($v > 100)
|
|
$v = 100;
|
|
return $v;
|
|
},
|
|
$load_exp,
|
|
array_fill(0, 3, $cores)
|
|
);
|
|
}
|
|
|
|
|
|
$datas = $load;
|
|
|
|
echo json_encode($datas); |