summaryrefslogtreecommitdiff
path: root/libs/load_average.php
diff options
context:
space:
mode:
authorShevAbam <shevabam@gmail.com>2014-06-18 10:15:18 +0200
committerShevAbam <shevabam@gmail.com>2014-06-18 10:15:18 +0200
commit3f6a49bae3ec616469f21dfbbbaff052055b0c0e (patch)
treec59f35c5a6b84b05a2bacd61e4c9655cfb554688 /libs/load_average.php
parent20705a550df5b13a544dc0865c6aef16e64c99d9 (diff)
- System : fix to get the distro name
- 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
Diffstat (limited to 'libs/load_average.php')
-rw-r--r--libs/load_average.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/libs/load_average.php b/libs/load_average.php
index 8eea8f9..6251c0e 100644
--- a/libs/load_average.php
+++ b/libs/load_average.php
@@ -1,21 +1,25 @@
<?php
-if (!($load_tmp = shell_exec('/bin/cat /proc/loadavg | /usr/bin/awk \'{print $1","$2","$3}\'')))
+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) {
- $v = (int)($value * 100);
+ function ($value, $cores) {
+ $v = (int)($value * 100 / $cores);
if ($v > 100)
$v = 100;
return $v;
},
- $load_exp
+ $load_exp,
+ array_fill(0, 3, $cores)
);
}