From beb7b8140c31f2c99166d00575fd5da2772168e8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 7 Jun 2010 19:17:00 +0000 Subject: [PATCH] Correctly control status of gateways. These code is tripled in these pages not sure what is the best solution. --- usr/local/www/status_gateway_groups.php | 39 ++++++-------- usr/local/www/status_gateways.php | 52 ++++++------------- .../www/widgets/widgets/gateways.widget.php | 51 +++++++----------- 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 353f0252be..d4f0d857f5 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 ""; $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 "". htmlspecialchars($member) .", $online"; } else { diff --git a/usr/local/www/status_gateways.php b/usr/local/www/status_gateways.php index fa9aa72f2a..eca1eec885 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"); Status Description - @@ -92,35 +90,21 @@ include("head.inc"); "; + echo ""; ?>
$online "; - $lastchange = $gateways_status[$monitor]['lastcheck']; + echo "
$online "; + $lastchange = $gateway['lastcheck']; if(!empty($lastchange)) { $lastchange = explode(" ", $lastchange); array_shift($lastchange); @@ -130,13 +114,11 @@ include("head.inc"); } else { print "Gathering data"; } - PRINT "
- - - + diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php index 7d675701a4..a9ba45ffd3 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; Loss Status - + + if(empty($monitor)) { + $monitor = $gateway['gateway']; + } + ?> @@ -73,30 +71,20 @@ $counter = 1; \" > "; $counter++; ?> @@ -104,7 +92,6 @@ $counter = 1;
$online