summaryrefslogtreecommitdiffstats
path: root/usr/local/www/includes
diff options
context:
space:
mode:
authorEspen Johansen <lsf@pfsense.org>2005-09-15 00:25:17 +0000
committerEspen Johansen <lsf@pfsense.org>2005-09-15 00:25:17 +0000
commitf155c21c514c66011b36f8fdad35d25a0fd3b689 (patch)
tree3ee192bc64c0f8cd458194b27b5f0c3d593d53e2 /usr/local/www/includes
parent52ff5992949ba0c08fd0f48f7c5a7658e5f6c7a6 (diff)
downloadpfsense-f155c21c514c66011b36f8fdad35d25a0fd3b689.zip
pfsense-f155c21c514c66011b36f8fdad35d25a0fd3b689.tar.gz
Hopefully CPU meter should be much more accurate now.
Diffstat (limited to 'usr/local/www/includes')
-rw-r--r--usr/local/www/includes/functions.inc.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php
index 822fb0c..597cc1e 100644
--- a/usr/local/www/includes/functions.inc.php
+++ b/usr/local/www/includes/functions.inc.php
@@ -34,21 +34,20 @@ function get_cputicks() {
}
function get_cpuusage($cpuTicks, $cpuTicks2) {
-
$diff = array();
- $diff['user'] = ($cpuTicks2[0] - $cpuTicks[0])+1;
- $diff['nice'] = ($cpuTicks2[1] - $cpuTicks[1])+1;
- $diff['sys'] = ($cpuTicks2[2] - $cpuTicks[2])+1;
- $diff['intr'] = ($cpuTicks2[3] - $cpuTicks[3])+1;
- $diff['idle'] = ($cpuTicks2[4] - $cpuTicks[4])+1;
+ $diff['user'] = ($cpuTicks2[0] - $cpuTicks[0]);
+ $diff['nice'] = ($cpuTicks2[1] - $cpuTicks[1]);
+ $diff['sys'] = ($cpuTicks2[2] - $cpuTicks[2]);
+ $diff['intr'] = ($cpuTicks2[3] - $cpuTicks[3]);
+ $diff['idle'] = ($cpuTicks2[4] - $cpuTicks[4]);
//echo "<!-- user: {$diff['user']} nice {$diff['nice']} sys {$diff['sys']} intr {$diff['intr']} idle {$diff['idle']} -->";
$totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle'];
- $totalused = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] - 1;
- $cpuUsage = round(100 * ($totalused / $totalDiff), 0);
-
- #$totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle'];
- #$cpuUsage = round(100 * (1 - $diff['idle'] / $totalDiff), 0);
+ $totalused = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'];
+ if (isset($totalused)&&$totalused <= 0) {
+ $totalused = 0.001;
+ }
+ $cpuUsage = floor(100 * ($totalused / $totalDiff));
return $cpuUsage;
}
OpenPOWER on IntegriCloud