Project

General

Profile

Download (5.02 KB) Statistics
| Branch: | Tag: | Revision:
1 719769d6 Seth Mos
<?php
2
/* $Id$ */
3
/*
4
	status_gateway_groups.php
5 5721595b Chris Buechler
	part of pfSense (https://www.pfsense.org)
6 719769d6 Seth Mos
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 719769d6 Seth Mos
	All rights reserved.
10
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32 42b0c921 Phil Davis
/*
33 1d333258 Scott Ullrich
	pfSense_MODULE:	routing
34
*/
35 719769d6 Seth Mos
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-status-gatewaygroups
38
##|*NAME=Status: Gateway Groups page
39
##|*DESCR=Allow access to the 'Status: Gateway Groups' page.
40
##|*MATCH=status_gateway_groups.php*
41
##|-PRIV
42
43 719769d6 Seth Mos
require("guiconfig.inc");
44
45 42b0c921 Phil Davis
if (!is_array($config['gateways']['gateway_group'])) {
46 719769d6 Seth Mos
	$config['gateways']['gateway_group'] = array();
47 42b0c921 Phil Davis
}
48 719769d6 Seth Mos
49
$a_gateway_groups = &$config['gateways']['gateway_group'];
50 8d712c32 Carlos Eduardo Ramos
$changedesc = gettext("Gateway Groups") . ": ";
51 719769d6 Seth Mos
52
$gateways_status = return_gateways_status();
53
54 8d712c32 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
55 b32dd0a6 jim-p
$shortcut_section = "gateway-groups";
56 719769d6 Seth Mos
include("head.inc");
57
58
?>
59
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61
<?php include("fbegin.inc"); ?>
62 42b0c921 Phil Davis
<table width="100%" border="0" cellpadding="0" cellspacing="0">
63
	<tr>
64
		<td>
65 719769d6 Seth Mos
<?php
66
			$tab_array = array();
67 8d712c32 Carlos Eduardo Ramos
			$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
68 d495dc51 jim-p
			$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
69 719769d6 Seth Mos
			display_top_tabs($tab_array);
70
?>
71 42b0c921 Phil Davis
		</td>
72
	</tr>
73
	<tr>
74
		<td>
75
			<div id="mainarea">
76
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
77
					<tr>
78
						<td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td>
79
						<td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td>
80
						<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
81
					</tr>
82
<?php
83
	$i = 0;
84
	foreach ($a_gateway_groups as $gateway_group):
85
?>
86
					<tr>
87
						<td class="listlr">
88
<?php
89
		echo $gateway_group['name'];
90
?>
91
						</td>
92
						<td class="listr">
93
							<table border='0'>
94
<?php
95
		/* process which priorities we have */
96
		$priorities = array();
97
		foreach ($gateway_group['item'] as $item) {
98
			$itemsplit = explode("|", $item);
99
			$priorities[$itemsplit[1]] = true;
100
		}
101
		$priority_count = count($priorities);
102
		ksort($priorities);
103
104
		echo "<tr>";
105
		foreach ($priorities as $number => $tier) {
106
			echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>";
107
		}
108
		echo "</tr>\n";
109
110
		/* inverse gateway group to gateway priority */
111
		$priority_arr = array();
112
		foreach ($gateway_group['item'] as $item) {
113
			$itemsplit = explode("|", $item);
114
			$priority_arr[$itemsplit[1]][] = $itemsplit[0];
115
		}
116
		ksort($priority_arr);
117
		$p = 1;
118
		foreach ($priority_arr as $number => $tier) {
119
			/* for each priority process the gateways */
120
			foreach ($tier as $member) {
121
				/* we always have $priority_count fields */
122
				echo "<tr>";
123
				$c = 1;
124
				while ($c <= $priority_count) {
125
					$monitor = lookup_gateway_monitor_ip_by_name($member);
126
					if ($p == $c) {
127
						$status = $gateways_status[$monitor]['status'];
128
						if (stristr($status, "down")) {
129
							$online = gettext("Offline");
130
							$bgcolor = "#F08080";  // lightcoral
131
						} elseif (stristr($status, "loss")) {
132
							$online = gettext("Warning, Packetloss");
133
							$bgcolor = "#F0E68C";  // khaki
134
						} elseif (stristr($status, "delay")) {
135
							$online = gettext("Warning, Latency");
136
							$bgcolor = "#F0E68C";  // khaki
137
						} elseif ($status == "none") {
138
							$online = gettext("Online");
139
							$bgcolor = "#90EE90";  // lightgreen
140 719769d6 Seth Mos
						} else {
141 42b0c921 Phil Davis
							$online = gettext("Gathering data");
142
							$bgcolor = "#ADD8E6";  // lightblue
143 719769d6 Seth Mos
						}
144 42b0c921 Phil Davis
						echo "<td bgcolor='$bgcolor'>&nbsp;". htmlspecialchars($member) .", $online&nbsp;</td>";
145
					} else {
146
						echo "<td>&nbsp;</td>";
147 719769d6 Seth Mos
					}
148 42b0c921 Phil Davis
					$c++;
149 719769d6 Seth Mos
				}
150 42b0c921 Phil Davis
				echo "</tr>\n";
151 719769d6 Seth Mos
			}
152 42b0c921 Phil Davis
			$p++;
153
		}
154
?>
155
							</table>
156
						</td>
157
						<td class="listbg">
158
							<?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
159
						</td>
160
					</tr>
161
<?php
162
		$i++;
163
	endforeach;
164
?>
165
166
				</table>
167
			</div>
168
		</td>
169
	</tr>
170 719769d6 Seth Mos
</table>
171
<?php include("fend.inc"); ?>
172
</body>
173
</html>