Project

General

Profile

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