Project

General

Profile

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