summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-03-02 02:22:49 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-03-02 02:22:49 +0000
commitc410cf554603cd3640a36ef5beabb87b7d59de5e (patch)
treedb96f00490d358417a50a240b0dada9e1cdd3a23 /usr
parent4d943b2fbffe74aaf1b1d1638998a455a243a521 (diff)
downloadpfsense-c410cf554603cd3640a36ef5beabb87b7d59de5e.zip
pfsense-c410cf554603cd3640a36ef5beabb87b7d59de5e.tar.gz
Use connection_aborted to detect if client still has index.php open. Use a 3 second sleep loop to DYNAMICALLY update the cpu status meter. Who needs SVG?
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/index.php40
1 files changed, 22 insertions, 18 deletions
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index fa3ed5e..24154b2 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -215,25 +215,29 @@ echo "<input style='border: 0px solid white;' size='30' name='swapusagemeter' id
</html>
<?php
-sleep(1);
-$cpuTicks = explode(" ", `/sbin/sysctl -n kern.cp_time`);
-sleep(2);
-$cpuTicks2 = explode(" ", `/sbin/sysctl -n kern.cp_time`);
-
-$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;
-$totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle'];
-$cpuUsage = round(100 * (1 - $diff['idle'] / $totalDiff), 0);
+While(!Connection_Aborted()) {
+
+ sleep(1);
+ $cpuTicks = explode(" ", `/sbin/sysctl -n kern.cp_time`);
+ sleep(2);
+ $cpuTicks2 = explode(" ", `/sbin/sysctl -n kern.cp_time`);
+
+ $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;
+ $totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle'];
+ $cpuUsage = round(100 * (1 - $diff['idle'] / $totalDiff), 0);
+
+ echo "<script language='javascript'>\n";
+ echo "document.cpuwidtha.style.width='" . $cpuUsage . "';\n";
+ echo "document.cpuwidthb.style.width='" . (100 - $cpuUsage) . "';\n";
+ echo "document.forms[0].cpumeter.value = '" . $cpuUsage . "%';\n";
+ echo "</script>\n";
-echo "<script language='javascript'>\n";
-echo "document.cpuwidtha.style.width='" . $cpuUsage . "';\n";
-echo "document.cpuwidthb.style.width='" . (100 - $cpuUsage) . "';\n";
-echo "document.forms[0].cpumeter.value = '" . $cpuUsage . "%';\n";
-echo "</script>\n";
+}
?>
OpenPOWER on IntegriCloud