summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim P <jim@pingle.org>2012-01-11 08:17:38 -0800
committerJim P <jim@pingle.org>2012-01-11 08:17:38 -0800
commitc6678f31b0e48b310bd49e392b6977a77c174e10 (patch)
tree8a6e89793eba072c83f07da0ef5bbf0ad2f1f0b8
parent12c7b5778418734a7ebbd816bb75522ca17a2a54 (diff)
parente9ca9b9a35c5e7c9c2fb6025c54da420d901cc49 (diff)
downloadpfsense-c6678f31b0e48b310bd49e392b6977a77c174e10.zip
pfsense-c6678f31b0e48b310bd49e392b6977a77c174e10.tar.gz
Merge pull request #37 from Joecowboy/master
Dashboard widget fixes and mods
-rw-r--r--usr/local/www/includes/functions.inc.php42
-rw-r--r--usr/local/www/javascript/index/ajax.js47
-rw-r--r--usr/local/www/widgets/javascript/cpu_graphs.js5
-rw-r--r--usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php8
-rw-r--r--usr/local/www/widgets/widgets/system_information.widget.php11
5 files changed, 74 insertions, 39 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php
index 6769d0e..8ceea4d 100644
--- a/usr/local/www/includes/functions.inc.php
+++ b/usr/local/www/includes/functions.inc.php
@@ -86,13 +86,25 @@ function get_uptime() {
$uphours = (int)($uptime / 3600);
$uptime %= 3600;
$upmins = (int)($uptime / 60);
+ $uptime %= 60;
+ $upsecs = (int)($uptime);
$uptimestr = "";
if ($updays > 1)
- $uptimestr .= "$updays days, ";
+ $uptimestr .= "$updays Days ";
else if ($updays > 0)
- $uptimestr .= "1 day, ";
- $uptimestr .= sprintf("%02d:%02d", $uphours, $upmins);
+ $uptimestr .= "1 Day ";
+
+ if ($uphours > 1)
+ $hours = "s";
+
+ if ($upmins > 1)
+ $minutes = "s";
+
+ if ($upmins > 1)
+ $seconds = "s";
+
+ $uptimestr .= sprintf("%02d Hour$hours %02d Minute$minutes %02d Second$seconds", $uphours, $upmins, $upsecs);
return $uptimestr;
}
@@ -148,12 +160,22 @@ function get_hwtype() {
}
function get_temp() {
- switch(get_hwtype()) {
- default:
- return;
- }
-
- return $ret;
+// switch(get_hwtype()) {
+// default:
+// return;
+// }
+//
+// return $ret;
+
+ $temp_out = "";
+ exec("/sbin/sysctl dev.cpu.0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout);
+ $temp_out = trim($dfout[0]);
+ if ($temp_out == "") {
+ exec("/sbin/sysctl hw.acpi.thermal.tz0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout);
+ $temp_out = trim($dfout[0]);
+ }
+
+ return $temp_out;
}
function disk_usage()
@@ -264,4 +286,4 @@ function get_interfacestatus() {
return $data;
}
-?>
+?> \ No newline at end of file
diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js
index 1759c05..bafdbff 100644
--- a/usr/local/www/javascript/index/ajax.js
+++ b/usr/local/www/javascript/index/ajax.js
@@ -1,9 +1,9 @@
-
/* Most widgets update their backend data every 10 seconds. 11 seconds
* will ensure that we update the GUI right after the stats are updated.
* Seconds * 1000 = value
*/
-var update_interval = 11000;
+var Seconds = 11;
+var update_interval = (Math.abs(Math.ceil(Seconds))-1)*1000 + 990;
function updateMeters() {
url = '/getstats.php';
@@ -16,7 +16,11 @@ function updateMeters() {
stats(data);
}
});
- setTimeout('updateMeters()', update_interval);
+ setTimer();
+}
+
+function setTimer() {
+ timeout = window.setTimeout('updateMeters()', update_interval);
}
function stats(x) {
@@ -27,17 +31,16 @@ function stats(x) {
else
return false;
}))
- return;
-
- updateCPU(values[0]);
- updateMemory(values[1]);
- updateUptime(values[2]);
- updateState(values[3]);
- updateTemp(values[4]);
- updateDateTime(values[5]);
- updateInterfaceStats(values[6]);
- updateInterfaces(values[7]);
- updateGatewayStats(values[8]);
+
+ updateUptime(values[2]);
+ updateDateTime(values[5]);
+ updateCPU(values[0]);
+ updateMemory(values[1]);
+ updateState(values[3]);
+ updateTemp(values[4]);
+ updateInterfaceStats(values[6]);
+ updateInterfaces(values[7]);
+ updateGatewayStats(values[8]);
}
function updateMemory(x) {
@@ -63,11 +66,12 @@ function updateCPU(x) {
}
function updateTemp(x) {
- if(jQuery("#tempmeter")) {
- jQuery("#tempmeter").val(x + 'C');
+ if(jQuery("#tempmeter"))
+ jQuery("#tempmeter").val(x + '\u00B0' + 'C');
+ if(jQuery('#tempwidtha'))
jQuery("#tempwidtha").css('width',x + 'px');
+ if(jQuery('#tempwidthb'))
jQuery("#tempwidthb").css('width',(100 - x) + 'px');
- }
}
function updateDateTime(x) {
@@ -111,8 +115,8 @@ function updateInterfaceStats(x){
function updateInterfaces(x){
if (widgetActive("interfaces")){
- interfaces = x.split("~");
- interfaces.each(function(iface){
+ interfaces_split = x.split("~");
+ interfaces_split.each(function(iface){
details = iface.split(",");
switch(details[1]) {
case "up":
@@ -149,6 +153,5 @@ function widgetActive(x) {
/* start updater */
jQuery(document).ready(function(){
- setTimeout('updateMeters()', update_interval);
-});
-
+ setTimer();
+}); \ No newline at end of file
diff --git a/usr/local/www/widgets/javascript/cpu_graphs.js b/usr/local/www/widgets/javascript/cpu_graphs.js
index a411912..3d91b5f 100644
--- a/usr/local/www/widgets/javascript/cpu_graphs.js
+++ b/usr/local/www/widgets/javascript/cpu_graphs.js
@@ -242,6 +242,5 @@ function GraphDraw(graph) {
for(var i = 0; i < count; i++)
graph['spans'][i].style.marginTop = getMargin(i);
- jQuery('#' + graph['spans'][count - 1]).fadeIn(500);
-}
-
+// jQuery('#' + graph['spans'][count - 1]).fadeIn(500);
+} \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php
index fa48610..a7e7882 100644
--- a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php
+++ b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php
@@ -61,12 +61,12 @@ require_once("functions.inc");
<script language="javascript" type="text/javascript">
// Graph 1
- graph[0] = GraphInitialize('GraphOutput', 200, 50, 2);
+ graph[0] = GraphInitialize('GraphOutput', 200, 50, 4);
graph_dir[0] = GL_END;
last_val[0] = Math.floor(Math.random() * 50);
last_val_span[0] = document.getElementById('LastValue0');
- //GraphSetVMax(graph[0], 100);
- //GraphDynamicScale(graph[0]);
+ GraphSetVMax(graph[0], 100);
+ GraphDynamicScale(graph[0]);
-</script>
+</script> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php
index 9a7dc55..7dab2cc 100644
--- a/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/usr/local/www/widgets/widgets/system_information.widget.php
@@ -200,6 +200,17 @@ $curcfg = $config['system']['firmware'];
<?= $mbufs_total ?>/<?= $mbufs_max ?>
</td>
</tr>
+ <?php if (get_temp() != ""): ?>
+ <tr>
+ <td width="25%" class="vncellt">Temperature</td>
+ <td width="75%" class="listr">
+ <?php $TempMeter = $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="<?= $TempMeter; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $TempMeter); ?>" 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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."&#176;C"; ?>" />
+ </td>
+ </tr>
+ <?php endif; ?>
<tr>
<td width="25%" class="vncellt">CPU usage</td>
<td width="75%" class="listr">
OpenPOWER on IntegriCloud