summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-06-07 19:17:00 +0000
committerErmal <eri@pfsense.org>2010-06-07 19:17:00 +0000
commitbeb7b8140c31f2c99166d00575fd5da2772168e8 (patch)
tree293c312fcfe20f1e83ef0acbd3f407c8722ea8a5
parent04969976308ab51b50408f9d804f3cd9af5a329d (diff)
downloadpfsense-beb7b8140c31f2c99166d00575fd5da2772168e8.zip
pfsense-beb7b8140c31f2c99166d00575fd5da2772168e8.tar.gz
Correctly control status of gateways. These code is tripled in these pages not sure what is the best solution.
-rwxr-xr-xusr/local/www/status_gateway_groups.php39
-rwxr-xr-xusr/local/www/status_gateways.php52
-rw-r--r--usr/local/www/widgets/widgets/gateways.widget.php51
3 files changed, 53 insertions, 89 deletions
diff --git a/usr/local/www/status_gateway_groups.php b/usr/local/www/status_gateway_groups.php
index 353f025..d4f0d85 100755
--- a/usr/local/www/status_gateway_groups.php
+++ b/usr/local/www/status_gateway_groups.php
@@ -116,29 +116,24 @@ include("head.inc");
echo "<tr>";
$c = 1;
while($c <= $priority_count) {
+ $monitor = lookup_gateway_monitor_ip_by_name($member);
if($p == $c) {
- $monitor = lookup_gateway_monitor_ip_by_name($member);
- switch($gateways_status[$monitor]['status']) {
- case "None":
- $online = "Online";
- $bgcolor = "lightgreen";
- break;
- case "\"down\"":
- $online = "Offline";
- $bgcolor = "lightcoral";
- break;
- case "\"delay\"":
- $online = "Latency";
- $bgcolor = "khaki";
- break;
- case "\"loss\"":
- $online = "Packetloss";
- $bgcolor = "khaki";
- break;
- default:
- $online = "Unknown";
- $bgcolor = "lightblue";
- break;
+ $status = $gateways_status[$monitor]['status'];
+ if (stristr($status, "down")) {
+ $online = "Offline";
+ $bgcolor = "lightcoral";
+ } elseif (stristr($status, "loss")) {
+ $online = "Warning, Packetloss";
+ $bgcolor = "khaki";
+ } elseif (stristr($status, "delay")) {
+ $online = "Warning, Latency";
+ $bgcolor = "khaki";
+ } elseif (stristr($status, "none")) {
+ $online = "Online";
+ $bgcolor = "lightgreen";
+ } else {
+ $online = "Unknown";
+ $bgcolor = "lightblue";
}
echo "<td bgcolor='$bgcolor'>". htmlspecialchars($member) .", $online</td>";
} else {
diff --git a/usr/local/www/status_gateways.php b/usr/local/www/status_gateways.php
index fa9aa72..eca1eec 100755
--- a/usr/local/www/status_gateways.php
+++ b/usr/local/www/status_gateways.php
@@ -42,7 +42,6 @@
require("guiconfig.inc");
$a_gateways = return_gateways_array();
-
$gateways_status = array();
$gateways_status = return_gateways_status();
@@ -76,8 +75,7 @@ include("head.inc");
<td width="30%" class="listhdrr">Status</td>
<td width="30%" class="listhdr">Description</td>
</tr>
- <?php foreach ($a_gateways as $gateway) {
- $i = 2;
+ <?php foreach ($gateways_status as $gateway) {
?>
<tr>
<td class="listlr">
@@ -92,35 +90,21 @@ include("head.inc");
<td class="listr" >
<table border="0" cellpadding="0" cellspacing="2">
<?php
- if($gateway['gateway'] == "dynamic") {
- $gateway['monitor'] = "127.0.0.{$i}";
- $i++;
- }
- $monitor = $gateway['monitor'];
- if(empty($monitor)) {
- $monitor = $gateway['gateway'];
- }
- switch($gateways_status[$monitor]['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;
+ if (stristr($gateway['status'], "down")) {
+ $online = "Offline";
+ $bgcolor = "lightcoral";
+ } elseif (stristr($gateway['status'], "loss")) {
+ $online = "Warning, Packetloss";
+ $bgcolor = "khaki";
+ } elseif (stristr($gateway['status'], "delay")) {
+ $online = "Warning, Latency";
+ $bgcolor = "khaki";
+ } elseif (stristr($gateway['status'], "none")) {
+ $online = "Online";
+ $bgcolor = "lightgreen";
}
-
- PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
- $lastchange = $gateways_status[$monitor]['lastcheck'];
+ echo "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
+ $lastchange = $gateway['lastcheck'];
if(!empty($lastchange)) {
$lastchange = explode(" ", $lastchange);
array_shift($lastchange);
@@ -130,13 +114,11 @@ include("head.inc");
} else {
print "Gathering data";
}
- PRINT "</td></tr>";
+ echo "</td></tr>";
?>
</table>
</td>
- <td class="listbg" >
- <?=$gateway['descr'];?></font>
- </td>
+ <td class="listbg"> <?=$a_gateway[$gateway['name']]['descr']; ?></td>
</tr>
<?php } ?>
</table>
diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php
index 7d67570..a9ba45f 100644
--- a/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/usr/local/www/widgets/widgets/gateways.widget.php
@@ -30,8 +30,6 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
-$a_gateways = return_gateways_array();
-
$gateways_status = array();
$gateways_status = return_gateways_status();
@@ -46,13 +44,13 @@ $counter = 1;
<td width="10%" class="listhdrr">Loss</td>
<td width="30%" class="listhdrr">Status</td>
</tr>
- <?php foreach ($a_gateways as $gateway) { ?>
+ <?php foreach ($gateways_status as $gateway) { ?>
<?php
$monitor = $gateway['monitor'];
- if(empty($monitor)) {
- $monitor = $gateway['gateway'];
- }
- ?>
+ if(empty($monitor)) {
+ $monitor = $gateway['gateway'];
+ }
+ ?>
<tr>
<td class="listlr" id="gateway<?= $counter; ?>">
<?=$gateway['name'];?>
@@ -73,30 +71,20 @@ $counter = 1;
<td class="listr" id=\"gateway<?=$counter?>\" >
<table border="0" cellpadding="0" cellspacing="2">
<?php
- $monitor = $gateway['monitor'];
- if(empty($monitor)) {
- $monitor = $gateway['gateway'];
- }
- switch($gateways_status[$monitor]['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 = "Gathering data";
- }
+ if (stristr($gateway['status'], "down")) {
+ $online = "Offline";
+ $bgcolor = "lightcoral";
+ } elseif (stristr($gateway['status'], "loss")) {
+ $online = "Warning, Packetloss";
+ $bgcolor = "khaki";
+ } elseif (stristr($gateway['status'], "delay")) {
+ $online = "Warning, Latency";
+ $bgcolor = "khaki";
+ } elseif (stristr($gateway['status'], "none")) {
+ $online = "Online";
+ $bgcolor = "lightgreen";
+ } else
+ $online = "Gathering data";
echo "<tr><td bgcolor=\"$bgcolor\" > $online </td>";
$counter++;
?>
@@ -104,7 +92,6 @@ $counter = 1;
</td>
</tr>
<?php
- $i++;
}
?>
</table>
OpenPOWER on IntegriCloud