diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-03-02 00:11:35 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-03-02 00:11:35 +0000 |
commit | 8dbbc3edfb237ce235fe62e7790505a16f8be452 (patch) | |
tree | e7303e33b99a7621bba00fc33f4041e8d3300d30 /usr/local/www/index.php | |
parent | 17f1b3b4613463c29b2efda5f7ee272dd8170dab (diff) | |
download | pfsense-8dbbc3edfb237ce235fe62e7790505a16f8be452.zip pfsense-8dbbc3edfb237ce235fe62e7790505a16f8be452.tar.gz |
Do not sleep for 3 seconds during the pages initial load. Instead sleep after the entire page has been rendered to find the cpu usage and use some javascript kung-fu to set the graphs accordingly
Diffstat (limited to 'usr/local/www/index.php')
-rwxr-xr-x | usr/local/www/index.php | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/usr/local/www/index.php b/usr/local/www/index.php index aefbf07..c08e9c5 100755 --- a/usr/local/www/index.php +++ b/usr/local/www/index.php @@ -61,6 +61,8 @@ if ($fd) { <link href="gui.css" rel="stylesheet" type="text/css"> </head> +<form> + <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> @@ -139,7 +141,6 @@ if ($fd) { <td width="75%" class="listr"> <?php $cpuTicks = explode(" ", `/sbin/sysctl -n kern.cp_time`); -sleep(3); $cpuTicks2 = explode(" ", `/sbin/sysctl -n kern.cp_time`); $diff = array(); @@ -148,16 +149,15 @@ $diff['nice'] = $cpuTicks2[1] - $cpuTicks[1]; $diff['sys'] = $cpuTicks2[2] - $cpuTicks[2]; $diff['intr'] = $cpuTicks2[3] - $cpuTicks[3]; $diff['idle'] = $cpuTicks2[4] - $cpuTicks[4]; - $totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle']; - $cpuUsage = round(100 * (1 - $diff['idle'] / $totalDiff), 0); echo "<img src='bar_left.gif' height='15' width='4' border='0' align='absmiddle'>"; -echo "<img src='bar_blue.gif' height='15' width='" . $cpuUsage . "' border='0' align='absmiddle'>"; -echo "<img src='bar_gray.gif' height='15' width='" . (100 - $cpuUsage) . "' border='0' align='absmiddle'>"; +echo "<img src='bar_blue.gif' height='15' name='cpuwidtha' id='cpuwidtha' width='" . $cpuUsage . "' border='0' align='absmiddle'>"; +echo "<img src='bar_gray.gif' height='15' name='cpuwidthb' id='cpuwidthb' width='" . (100 - $cpuUsage) . "' border='0' align='absmiddle'>"; echo "<img src='bar_right.gif' height='15' width='5' border='0' align='absmiddle'> "; -echo $cpuUsage . "%"; +echo "<input style='border: 0px solid white;' size='4' name='cpumeter' id='cpumeter' value='{$cpuUsage}%'>"; +//echo $cpuUsage . "%"; ?> </td> </tr> @@ -178,7 +178,8 @@ echo " <img src='bar_left.gif' height='15' width='4' border='0' align='absmiddle echo "<img src='bar_blue.gif' height='15' width='" . $memUsage . "' border='0' align='absmiddle'>"; echo "<img src='bar_gray.gif' height='15' width='" . (100 - $memUsage) . "' border='0' align='absmiddle'>"; echo "<img src='bar_right.gif' height='15' width='5' border='0' align='absmiddle'> "; -echo $memUsage . "%"; +echo "<input style='border: 0px solid white;' size='4' name='memusagemeter' id='memusagemeter' value='{$memUsage}%'>"; +//echo $memUsage . "%"; ?> </td> </tr> @@ -196,7 +197,8 @@ echo "<img src='bar_left.gif' height='15' width='4' border='0' align='absmiddle' echo "<img src='bar_blue.gif' height='15' width='" . $swapUsage . "' border='0' align='absmiddle'>"; echo "<img src='bar_gray.gif' height='15' width='" . (100 - $swapUsage) . "' border='0' align='absmiddle'>"; echo "<img src='bar_right.gif' height='15' width='5' border='0' align='absmiddle'> "; -echo $swapUsage . "%"; +echo "<input style='border: 0px solid white;' size='4' name='swapusagemeter' id='swapusagemeter' value='{$swapUsage}%'>"; +//echo $swapUsage . "%"; ?> @@ -208,5 +210,27 @@ echo $swapUsage . "%"; <?php include("fend.inc"); ?> </body> </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]; +$diff['nice'] = $cpuTicks2[1] - $cpuTicks[1]; +$diff['sys'] = $cpuTicks2[2] - $cpuTicks[2]; +$diff['intr'] = $cpuTicks2[3] - $cpuTicks[3]; +$diff['idle'] = $cpuTicks2[4] - $cpuTicks[4]; +$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"; + +?> |