Project

General

Profile

Download (5.22 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_gateway_groups.php
5
	part of pfSense (https://www.pfsense.org)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	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
/*
33
	pfSense_MODULE: routing
34
*/
35

    
36
##|+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
define('COLOR', true);
44
define('LIGHTGREEN', '#90EE90');
45
define('LIGHTCORAL', '#F08080');
46
define('KHAKI',		 '#F0E68C');
47
define('LIGHTGRAY',	 '#D3D3D3');
48
define('LIGHTBLUE',	 '#ADD8E6');
49
define('WHITE',		 '#FFFFFF');
50

    
51
require("guiconfig.inc");
52

    
53
if (!is_array($config['gateways']['gateway_group']))
54
	$config['gateways']['gateway_group'] = array();
55

    
56
$a_gateway_groups = &$config['gateways']['gateway_group'];
57
$changedesc = gettext("Gateway Groups") . ": ";
58

    
59
$gateways_status = return_gateways_status();
60

    
61
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
62
$shortcut_section = "gateway-groups";
63
include("head.inc");
64

    
65
$tab_array = array();
66
$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
67
$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
68
display_top_tabs($tab_array);
69
?>
70

    
71
<div class="table-responsive">
72
	<table class="table table-hover table-condensed table-striped">
73
		<thead>
74
			<tr>
75
				<th><?=gettext("Group Name"); ?></th>
76
				<th><?=gettext("Gateways"); ?></th>
77
				<th><?=gettext("Description"); ?></th>
78
			</tr>
79
		</thead>
80
		<tbody>
81
			<?php foreach ($a_gateway_groups as $gateway_group): ?>
82
			<tr>
83
				<td>
84
					<?=htmlspecialchars($gateway_group['name'])?>
85
				</td>
86
				<td>
87
					<table class="table table-bordered table-condensed">
88
<?php
89
						/* process which priorities we have */
90
						$priorities = array();
91
						foreach($gateway_group['item'] as $item) {
92
							$itemsplit = explode("|", $item);
93
							$priorities[$itemsplit[1]] = true;
94
						}
95
						$priority_count = count($priorities);
96
						ksort($priorities);
97
?>
98
						<thead>
99
							<tr>
100
<?php
101
							// Make a column for each tier
102
							foreach($priorities as $number => $tier) {
103
								echo "<th>" . sprintf(gettext("Tier %s"), $number) . "</th>";
104
							}
105
?>
106
							</tr>
107
						</thead>
108
						<tbody>
109
<?php
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
?>
123
							<tr>
124
<?php
125
									$c = 1;
126
									while($c <= $priority_count) {
127
										$monitor = lookup_gateway_monitor_ip_by_name($member);
128
										if($p == $c) {
129
											$status = $gateways_status[$monitor]['status'];
130
											if (stristr($status, "down")) {
131
													$online = gettext("Offline");
132
													$bgcolor = LIGHTCORAL;
133
											} elseif (stristr($status, "loss")) {
134
													$online = gettext("Warning, Packetloss");
135
													$bgcolor = KHAKI;
136
											} elseif (stristr($status, "delay")) {
137
													$online = gettext("Warning, Latency");
138
													$bgcolor = KHAKI;
139
											} elseif ($status == "none") {
140
													$online = gettext("Online");
141
													$bgcolor = LIGHTGREEN;
142
											} else {
143
												$online = gettext("Gathering data");
144
												$bgcolor = LIGHTBLUE;
145
											}
146

    
147
											if(!COLOR)
148
												$bgcolor = WHITE;
149
?>
150
								<td bgcolor="<?=$bgcolor?>">
151
									<?=htmlspecialchars($member);?>,<br /><?=$online?>
152
								</td>
153

    
154
<?php
155
										} else {
156
?>
157
								<td>
158
								</td>
159
<?php							}
160
										$c++;
161
									}
162
?>
163
							</tr>
164
<?php
165
								}
166
								$p++;
167
							}
168
?>
169
						</tbody>
170
					</table>
171
				</td>
172
				<td>
173
					<?=htmlspecialchars($gateway_group['descr'])?>
174
				</td>
175
			</tr>
176
			<?php endforeach; ?>
177
		</tbody>
178
	</table>
179
</div>
180

    
181
<?php include("foot.inc");
(174-174/241)