summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-03-11 17:28:17 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-03-11 17:28:37 -0400
commit3dfa6a5214276556ce089a17e597ac4a345fe319 (patch)
treeb133221929d95da82c453928674079f5a93fb405 /usr/local
parent00707bc52dec72ada2b2b142ffbf4dccc8025c12 (diff)
downloadpfsense-3dfa6a5214276556ce089a17e597ac4a345fe319.zip
pfsense-3dfa6a5214276556ce089a17e597ac4a345fe319.tar.gz
Add ajax mojo to gateway status widget
Diffstat (limited to 'usr/local')
-rw-r--r--usr/local/www/includes/functions.inc.php41
-rw-r--r--usr/local/www/includes/javascript.inc.php1
-rw-r--r--usr/local/www/includes/sajax.class.php2
-rw-r--r--usr/local/www/javascript/index/sajax.js14
-rwxr-xr-xusr/local/www/sajax/index.sajax.php2
-rw-r--r--usr/local/www/widgets/include/interface_statistics.inc2
-rw-r--r--usr/local/www/widgets/widgets/gateways.widget.php17
7 files changed, 65 insertions, 14 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php
index 8f549d6..218f732 100644
--- a/usr/local/www/includes/functions.inc.php
+++ b/usr/local/www/includes/functions.inc.php
@@ -6,7 +6,6 @@ if(Connection_Aborted()) {
require_once("config.inc");
-
function get_stats() {
$stats['cpu'] = cpu_usage();
$stats['mem'] = mem_usage();
@@ -16,12 +15,48 @@ function get_stats() {
$stats['datetime'] = update_date_time();
$stats['interfacestatistics'] = get_interfacestats();
$stats['interfacestatus'] = get_interfacestatus();
-
+ $stats['gateways'] = get_gatewaystats();
$stats = join("|", $stats);
-
return $stats;
}
+function get_gatewaystats() {
+ $gateways_status = array();
+ $gateways_status = return_gateways_status();
+ $data = "";
+ $isfirst = true;
+ foreach($gateways_status as $gw) {
+ if(!$isfirst)
+ $data .= ",";
+ $isfirst = false;
+ $data .= $gw['name'] . ",";
+ $data .= $gw['gateway'] . ",";
+ $data .= $gw['delay'] . ",";
+ $data .= $gw['loss'] . ",";
+ switch($gw['status']) {
+ case "None":
+ $online = "Online";
+ $bgcolor = "lightgreen";
+ break;
+ case "\"down\"":
+ $online = "Offline";
+ $bgcolor = "lightcoral";
+ break;
+ case "\"delay\"":
+ $online = "Warning, Latency";
+ $bgcolor = "khaki";
+ break;
+ case "\"loss\"":
+ $online = "Warning, Packetloss";
+ $bgcolor = "khaki";
+ break;
+ default:
+ $online = "No data";
+ }
+ $data .= "<tr><td id=\"gateway{$counter}\" bgcolor=\"$bgcolor\" > $online </td>";
+ }
+ return $data;
+}
function get_uptime() {
$boottime = "";
diff --git a/usr/local/www/includes/javascript.inc.php b/usr/local/www/includes/javascript.inc.php
index d1acf17..3cbb64e 100644
--- a/usr/local/www/includes/javascript.inc.php
+++ b/usr/local/www/includes/javascript.inc.php
@@ -10,7 +10,6 @@
$top_javascript_files = array();
$bottom_javascript_files = array();
-
$top_javascript_files['firewall_rules_edit.php'][] = 'autosuggest.js';
$top_javascript_files['firewall_rules_edit.php'][] = 'suggestions.js';
$top_javascript_files['firewall_rules_edit.php'][] = 'firewall_rules_edit.js';
diff --git a/usr/local/www/includes/sajax.class.php b/usr/local/www/includes/sajax.class.php
index 58e9393..ee38add 100644
--- a/usr/local/www/includes/sajax.class.php
+++ b/usr/local/www/includes/sajax.class.php
@@ -261,4 +261,4 @@ class sajax {
} // End sajax class
-?>
+?> \ No newline at end of file
diff --git a/usr/local/www/javascript/index/sajax.js b/usr/local/www/javascript/index/sajax.js
index c195cf0..c8f31f5 100644
--- a/usr/local/www/javascript/index/sajax.js
+++ b/usr/local/www/javascript/index/sajax.js
@@ -27,7 +27,8 @@ function stats(x) {
updateDateTime(values[5]);
updateInterfaceStats(values[6]);
updateInterfaces(values[7]);
-
+ updateGatewayStats(values[8]);
+
}
function updateMemory(x)
@@ -81,6 +82,17 @@ function updateState(x)
document.getElementById("pfstate").value = x;
}
+function updateGatewayStats(x){
+ if (widgetActive("gateways")){
+ gateways_split = x.split(",");
+ var counter = 1;
+ for (var y=0; y<gateways_split.length-1; y++){
+ document.getElementById('gateway' + counter).innerHTML = gateways_split[y];
+ counter++;
+ }
+ }
+}
+
function updateInterfaceStats(x){
if (widgetActive("interface_statistics")){
statistics_split = x.split(",");
diff --git a/usr/local/www/sajax/index.sajax.php b/usr/local/www/sajax/index.sajax.php
index 8be40ab..13a5acb 100755
--- a/usr/local/www/sajax/index.sajax.php
+++ b/usr/local/www/sajax/index.sajax.php
@@ -11,4 +11,4 @@
$oSajax = new sajax();
$oSajax->sajax_export("get_stats");
$oSajax->sajax_handle_client_request();
-?>
+?> \ No newline at end of file
diff --git a/usr/local/www/widgets/include/interface_statistics.inc b/usr/local/www/widgets/include/interface_statistics.inc
index 781a018..c789418 100644
--- a/usr/local/www/widgets/include/interface_statistics.inc
+++ b/usr/local/www/widgets/include/interface_statistics.inc
@@ -2,6 +2,4 @@
//set variable for custom title
$interface_statistics_title = "Interface Statistics";
$interface_statistics_title_link = "status_interfaces.php";
-
-
?> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php
index 68567df..2af3ea3 100644
--- a/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/usr/local/www/widgets/widgets/gateways.widget.php
@@ -35,6 +35,8 @@ $a_gateways = return_gateways_array();
$gateways_status = array();
$gateways_status = return_gateways_status();
+$counter = 1;
+
?>
<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
@@ -52,17 +54,21 @@ $gateways_status = return_gateways_status();
}
?>
<tr>
- <td class="listlr">
+ <td class="listlr" id="gateway<?= $counter; ?>">
<?=$gateway['name'];?>
+ <?php $counter++; ?>
</td>
- <td class="listr" align="center" >
+ <td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateway['gateway'];?>
+ <?php $counter++; ?>
</td>
- <td class="listr" align="center" >
+ <td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateways_status[$monitor]['delay'];?>
+ <?php $counter++; ?>
</td>
- <td class="listr" align="center" >
+ <td class="listr" align="center" id="gateway<?= $counter; ?>">
<?=$gateways_status[$monitor]['loss'];?>
+ <?php $counter++; ?>
</td>
<td class="listr" >
<table border="0" cellpadding="0" cellspacing="2">
@@ -91,7 +97,8 @@ $gateways_status = return_gateways_status();
default:
$online = "No data";
}
- echo "<tr><td bgcolor=\"$bgcolor\" > $online </td>";
+ echo "<tr><td id=\"gateway{$counter}\" bgcolor=\"$bgcolor\" > $online </td>";
+ $counter++;
?>
</table>
</td>
OpenPOWER on IntegriCloud