mirror of
https://github.com/ShaYmez/ezservermonitor-web.git
synced 2024-11-15 21:01:46 -05:00
3f6a49bae3
- Services : fix on service names with accent - Services : ability to specify a host for each service - Network usage : fix to retrieve the name of the network interfaces - Memory : the cached and buffers memory are added to free memory now - Load Average : taking into account the number of cores - Disk usage : new option to hide tmpfs mountpoints - General : remove all PHP short tags
29 lines
559 B
PHP
29 lines
559 B
PHP
<?php
|
|
|
|
if (!($load_tmp = shell_exec('cat /proc/loadavg | awk \'{print $1","$2","$3}\'')))
|
|
{
|
|
$load = array(0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
// Number of cores
|
|
$cores = (int)shell_exec('grep -c ^processor /proc/cpuinfo');
|
|
|
|
$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); |