diff options
author | Bill Marquette <billm@pfsense.org> | 2005-09-15 03:21:17 +0000 |
---|---|---|
committer | Bill Marquette <billm@pfsense.org> | 2005-09-15 03:21:17 +0000 |
commit | 7979a809331c706f621fd4d6d40b667a81fa806a (patch) | |
tree | c57b2a29174fddef03e48b50cc56b25700d3eb78 /usr/local/www | |
parent | 1804023da9ad604cb57af7e934352ef84e127736 (diff) | |
download | pfsense-7979a809331c706f621fd4d6d40b667a81fa806a.zip pfsense-7979a809331c706f621fd4d6d40b667a81fa806a.tar.gz |
Make temp monitor really work - make a little more modular too
Diffstat (limited to 'usr/local/www')
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 23 | ||||
-rwxr-xr-x | usr/local/www/index.php | 12 | ||||
-rw-r--r-- | usr/local/www/javascript/index/sajax.js | 9 |
3 files changed, 29 insertions, 15 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index dddc5ab..9878105 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -65,8 +65,27 @@ function get_pfstate() { return $curentries . $maxstates; } -function get_temp($type) { - switch($type) { +function has_temp() { + if(`/sbin/dmesg -a | /usr/bin/grep net4801` <> "") { + /* Initialize hw monitor */ + exec("/usr/local/sbin/env4801 -i"); + return true; + } + + /* should only reach here if there is no hardware monitor */ + return false; +} + +function get_hwtype() { + if(`/sbin/dmesg -a | /usr/bin/grep net4801` <> "") { + return "4801"; + } + + return; +} + +function get_temp() { + switch(get_hwtype()) { case '4801': $ret = rtrim(`/usr/local/sbin/env4801 | /usr/bin/grep Temp |/usr/bin/cut -c24-25`); break; diff --git a/usr/local/www/index.php b/usr/local/www/index.php index be6e120..e9d5ef4 100755 --- a/usr/local/www/index.php +++ b/usr/local/www/index.php @@ -211,19 +211,15 @@ include("fbegin.inc"); <?php /* XXX - Stub in the HW monitor for net4801 - needs to use platform var's once we start using them */ /* XXX - this should be grep net4801, but the graph doesn't update right now and I don't want to fix it right now - billm */ - $is4801 = `/sbin/dmesg -a | /usr/bin/grep net4801`; - if($is4801 <> ""): - exec("/usr/local/sbin/env4801 -i"); - $hwtype = "4801"; - + if(has_temp()): ?> <tr> <td width='25%' class='vncellt'>Temperature</td> <td width='75%' class='listr'> - <?php $temp = get_temp($hwtype); ?> - <img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" name="Tempwidtha" id="tempwidtha" width="<?= $temp; ?>" border="0" align="middle" alt="blue bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" name="Tempwidthb" id="tempwidthb" width="<?= (100 - $temp); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> + <?php $temp = get_temp(); ?> + <img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" name="tempwidtha" id="tempwidtha" width="<?= $temp; ?>" border="0" align="middle" alt="blue bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $temp); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - <input style="border: 0px solid white;" size="30" name="Tempmeter" id="Tempmeter" value="<?= $temp."C"; ?>" /> + <input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."C"; ?>" /> </td> </tr> <?php endif; ?> diff --git a/usr/local/www/javascript/index/sajax.js b/usr/local/www/javascript/index/sajax.js index 036b38d..9067b3f 100644 --- a/usr/local/www/javascript/index/sajax.js +++ b/usr/local/www/javascript/index/sajax.js @@ -27,11 +27,10 @@ function updateCPU(x) function updateTemp(x) { - if(document.getElementById("tempmeter")) { - document.getElementById("tempmeter").value = x + '%'; - - document.getElementById("tempwidtha").style.width = x + 'px'; - document.getElementById("tempwidthb").style.width = (100 - x) + 'px'; + if(document.getElementById("tempmeter") != null) { + document.getElementById("tempmeter").value = x + '%'; + document.getElementById("tempwidtha").style.width = x + 'px'; + document.getElementById("tempwidthb").style.width = (100 - x) + 'px'; } } |