Project

General

Profile

Download (5.14 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
	Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>.
8
	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
$changedesc = "Gateway Groups: ";
49
50
$gateways_status = return_gateways_status();
51
52 ea0f9959 Seth Mos
$pgtitle = array("Status","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
			$tab_array[0] = array("Gateways", false, "status_gateways.php");
65
			$tab_array[1] = array("Groups", true, "status_gateway_groups.php");
66
			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
                  <td width="20%" class="listhdrr">Group Name</td>
75
                  <td width="50%" class="listhdrr">Gateways</td>
76
                  <td width="30%" class="listhdr">Description</td>
77
		</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
				echo "<td width='120'>Tier $number</td>";
101
			}
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
						if($p == $c) {
120
							$monitor = lookup_gateway_monitor_ip_by_name($member);
121
							switch($gateways_status[$monitor]['status']) {
122
							        case "None":
123
							                $online = "Online";
124
							                $bgcolor = "lightgreen";
125
							                break;
126
							        case "\"down\"":
127
							                $online = "Offline";
128
							                $bgcolor = "lightcoral";
129
							                break;
130
							        case "\"delay\"":
131 7cf4fd8f Seth Mos
							                $online = "Latency";
132 719769d6 Seth Mos
							                $bgcolor = "khaki";
133
							                break;
134
							        case "\"loss\"":
135 7cf4fd8f Seth Mos
							                $online = "Packetloss";
136 719769d6 Seth Mos
							                $bgcolor = "khaki";
137
							                break;
138 7cf4fd8f Seth Mos
								default:
139
							                $online = "Unknown";
140
							                $bgcolor = "lightblue";
141
							                break;
142 719769d6 Seth Mos
							}
143 7cf4fd8f Seth Mos
							echo "<td bgcolor='$bgcolor'>". htmlspecialchars($member) .", $online</td>";
144 719769d6 Seth Mos
						} else {
145
							echo "<td>&nbsp;</td>";
146
						}
147
						$c++;
148
					}
149
					echo "</tr>\n";
150
				}
151
				$p++;
152
			}
153
		    ?>
154
			</table>
155
                  </td>
156
                  <td class="listbg">
157 2792f9fe Scott Ullrich
                    <?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
158 719769d6 Seth Mos
                  </td>
159
		</tr>
160
			  <?php $i++; endforeach; ?>
161
162
	</table>
163
     </div>
164
    </td>
165
  </tr>
166
</table>
167
<?php include("fend.inc"); ?>
168
</body>
169
</html>