mirror of
https://github.com/YunoHost-Apps/linuxdash_ynh.git
synced 2024-09-03 19:36:07 +02:00
22 lines
561 B
PHP
22 lines
561 B
PHP
|
<?php
|
||
|
|
||
|
exec('/bin/grep -c ^processor /proc/cpuinfo', $resultNumberOfCores);
|
||
|
$numberOfCores = $resultNumberOfCores[0];
|
||
|
|
||
|
exec(
|
||
|
'/bin/cat /proc/loadavg | /usr/bin/awk \'{print $1","$2","$3}\'',
|
||
|
$resultLoadAvg
|
||
|
);
|
||
|
$loadAvg = explode(',', $resultLoadAvg[0]);
|
||
|
|
||
|
header('Content-Type: application/json; charset=UTF-8');
|
||
|
echo json_encode(
|
||
|
array_map(
|
||
|
function ($value, $numberOfCores) {
|
||
|
return array($value, (int)($value * 100 / $numberOfCores));
|
||
|
},
|
||
|
$loadAvg,
|
||
|
array_fill(0, count($loadAvg), $numberOfCores)
|
||
|
)
|
||
|
);
|