mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Correctly control status of gateways. These code is tripled in these pages not sure what is the best solution.
This commit is contained in:
parent
0496997630
commit
beb7b8140c
@ -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 {
|
||||
|
||||
@ -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++;
|
||||
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";
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user