Project

General

Profile

Download (5.64 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 1d333258 Scott Ullrich
/*	
33
	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
if (!is_array($config['gateways']['gateway_group']))
46
	$config['gateways']['gateway_group'] = array();
47
48
$a_gateway_groups = &$config['gateways']['gateway_group'];
49 8d712c32 Carlos Eduardo Ramos
$changedesc = gettext("Gateway Groups") . ": ";
50 719769d6 Seth Mos
51
$gateways_status = return_gateways_status();
52
53 8d712c32 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
54 b32dd0a6 jim-p
$shortcut_section = "gateway-groups";
55 719769d6 Seth Mos
include("head.inc");
56
57
?>
58
59
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
60
<?php include("fbegin.inc"); ?>
61
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
62
		<tr>
63
		  <td>
64
<?php
65
			$tab_array = array();
66 8d712c32 Carlos Eduardo Ramos
			$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
67 d495dc51 jim-p
			$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
68 719769d6 Seth Mos
			display_top_tabs($tab_array);
69
?>
70
</td></tr>
71
 <tr>
72
   <td>
73
	<div id="mainarea">
74
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
75
                <tr>
76 8d712c32 Carlos Eduardo Ramos
                  <td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td>
77
                  <td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td>
78
                  <td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
79 719769d6 Seth Mos
		</tr>
80
			  <?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
81
                <tr>
82
                  <td class="listlr">
83
                    <?php
84
			echo $gateway_group['name'];
85
			?>
86
			
87
                  </td>
88
                  <td class="listr">
89
			<table border='0'>
90
                <?php
91
			/* process which priorities we have */
92
			$priorities = array();
93
			foreach($gateway_group['item'] as $item) {
94
				$itemsplit = explode("|", $item);
95
				$priorities[$itemsplit[1]] = true;
96
			}
97
			$priority_count = count($priorities);
98 754d81a5 Seth Mos
			ksort($priorities);
99 719769d6 Seth Mos
100
			echo "<tr>";
101
			foreach($priorities as $number => $tier) {
102 e36c52f4 Erik Fonnesbeck
				echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>";
103 719769d6 Seth Mos
			}
104
			echo "</tr>\n";
105
106
			/* inverse gateway group to gateway priority */
107
			$priority_arr = array();
108
			foreach($gateway_group['item'] as $item) {
109
				$itemsplit = explode("|", $item);
110
				$priority_arr[$itemsplit[1]][] = $itemsplit[0];
111
			}
112 754d81a5 Seth Mos
			ksort($priority_arr);
113 719769d6 Seth Mos
			$p = 1;
114
			foreach($priority_arr as $number => $tier) {
115
				/* for each priority process the gateways */
116
				foreach($tier as $member) {
117
					/* we always have $priority_count fields */
118
					echo "<tr>";
119
					$c = 1;
120
					while($c <= $priority_count) {
121 beb7b814 Ermal
						$monitor = lookup_gateway_monitor_ip_by_name($member);
122 719769d6 Seth Mos
						if($p == $c) {
123 beb7b814 Ermal
							$status = $gateways_status[$monitor]['status'];
124
							if (stristr($status, "down")) {
125 8d712c32 Carlos Eduardo Ramos
                                        			$online = gettext("Offline");
126 a0c0e8ae Colin Fleming
                                        			$bgcolor = "#F08080";  // lightcoral
127 beb7b814 Ermal
                                			} elseif (stristr($status, "loss")) {
128 8d712c32 Carlos Eduardo Ramos
                                        			$online = gettext("Warning, Packetloss");
129 a0c0e8ae Colin Fleming
                                        			$bgcolor = "#F0E68C";  // khaki
130 beb7b814 Ermal
                                			} elseif (stristr($status, "delay")) {
131 8d712c32 Carlos Eduardo Ramos
                                        			$online = gettext("Warning, Latency");
132 a0c0e8ae Colin Fleming
                                        			$bgcolor = "#F0E68C";  // khaki
133 096ee9c2 Ermal
                                			} elseif ($status == "none") {
134 8d712c32 Carlos Eduardo Ramos
                                        			$online = gettext("Online");
135 a0c0e8ae Colin Fleming
                                        			$bgcolor = "#90EE90";  // lightgreen
136 beb7b814 Ermal
                                			} else {
137 7ec17767 Ermal
								$online = gettext("Gathering data");
138 a0c0e8ae Colin Fleming
								$bgcolor = "#ADD8E6";  // lightblue
139 719769d6 Seth Mos
							}
140 a0c0e8ae Colin Fleming
							echo "<td bgcolor='$bgcolor'>&nbsp;". htmlspecialchars($member) .", $online&nbsp;</td>";
141 719769d6 Seth Mos
						} else {
142
							echo "<td>&nbsp;</td>";
143
						}
144
						$c++;
145
					}
146
					echo "</tr>\n";
147
				}
148
				$p++;
149
			}
150
		    ?>
151
			</table>
152
                  </td>
153
                  <td class="listbg">
154 2792f9fe Scott Ullrich
                    <?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
155 719769d6 Seth Mos
                  </td>
156
		</tr>
157
			  <?php $i++; endforeach; ?>
158
159
	</table>
160
     </div>
161
    </td>
162
  </tr>
163
</table>
164
<?php include("fend.inc"); ?>
165
</body>
166
</html>