diff options
Diffstat (limited to 'libs/load_average.php')
-rw-r--r-- | libs/load_average.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/load_average.php b/libs/load_average.php new file mode 100644 index 0000000..8eea8f9 --- /dev/null +++ b/libs/load_average.php @@ -0,0 +1,25 @@ +<?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);
\ No newline at end of file |