Project

General

Profile

Download (5.11 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
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-status-gatewaygroups
34
##|*NAME=Status: Gateway Groups page
35
##|*DESCR=Allow access to the 'Status: Gateway Groups' page.
36
##|*MATCH=status_gateway_groups.php*
37
##|-PRIV
38
39
40 719769d6 Seth Mos
require("guiconfig.inc");
41
42
if (!is_array($config['gateways']['gateway_group']))
43
	$config['gateways']['gateway_group'] = array();
44
45
$a_gateway_groups = &$config['gateways']['gateway_group'];
46
$changedesc = "Gateway Groups: ";
47
48
$gateways_status = return_gateways_status();
49
50 ea0f9959 Seth Mos
$pgtitle = array("Status","Gateway Groups");
51 719769d6 Seth Mos
include("head.inc");
52
53
?>
54
55
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
56
<?php include("fbegin.inc"); ?>
57
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
58
		<tr>
59
		  <td>
60
<?php
61
			$tab_array = array();
62
			$tab_array[0] = array("Gateways", false, "status_gateways.php");
63
			$tab_array[1] = array("Groups", true, "status_gateway_groups.php");
64
			display_top_tabs($tab_array);
65
?>
66
</td></tr>
67
 <tr>
68
   <td>
69
	<div id="mainarea">
70
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
71
                <tr>
72
                  <td width="20%" class="listhdrr">Group Name</td>
73
                  <td width="50%" class="listhdrr">Gateways</td>
74
                  <td width="30%" class="listhdr">Description</td>
75
		</tr>
76
			  <?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
77
                <tr>
78
                  <td class="listlr">
79
                    <?php
80
			echo $gateway_group['name'];
81
			?>
82
			
83
                  </td>
84
                  <td class="listr">
85
			<table border='0'>
86
                <?php
87
			/* process which priorities we have */
88
			$priorities = array();
89
			foreach($gateway_group['item'] as $item) {
90
				$itemsplit = explode("|", $item);
91
				$priorities[$itemsplit[1]] = true;
92
			}
93
			$priority_count = count($priorities);
94 754d81a5 Seth Mos
			ksort($priorities);
95 719769d6 Seth Mos
96
			echo "<tr>";
97
			foreach($priorities as $number => $tier) {
98
				echo "<td width='120'>Tier $number</td>";
99
			}
100
			echo "</tr>\n";
101
102
			/* inverse gateway group to gateway priority */
103
			$priority_arr = array();
104
			foreach($gateway_group['item'] as $item) {
105
				$itemsplit = explode("|", $item);
106
				$priority_arr[$itemsplit[1]][] = $itemsplit[0];
107
			}
108 754d81a5 Seth Mos
			ksort($priority_arr);
109 719769d6 Seth Mos
			$p = 1;
110
			foreach($priority_arr as $number => $tier) {
111
				/* for each priority process the gateways */
112
				foreach($tier as $member) {
113
					/* we always have $priority_count fields */
114
					echo "<tr>";
115
					$c = 1;
116
					while($c <= $priority_count) {
117
						if($p == $c) {
118
							$monitor = lookup_gateway_monitor_ip_by_name($member);
119
							switch($gateways_status[$monitor]['status']) {
120
							        case "None":
121
							                $online = "Online";
122
							                $bgcolor = "lightgreen";
123
							                break;
124
							        case "\"down\"":
125
							                $online = "Offline";
126
							                $bgcolor = "lightcoral";
127
							                break;
128
							        case "\"delay\"":
129 7cf4fd8f Seth Mos
							                $online = "Latency";
130 719769d6 Seth Mos
							                $bgcolor = "khaki";
131
							                break;
132
							        case "\"loss\"":
133 7cf4fd8f Seth Mos
							                $online = "Packetloss";
134 719769d6 Seth Mos
							                $bgcolor = "khaki";
135
							                break;
136 7cf4fd8f Seth Mos
								default:
137
							                $online = "Unknown";
138
							                $bgcolor = "lightblue";
139
							                break;
140 719769d6 Seth Mos
							}
141 7cf4fd8f Seth Mos
							echo "<td bgcolor='$bgcolor'>". htmlspecialchars($member) .", $online</td>";
142 719769d6 Seth Mos
						} else {
143
							echo "<td>&nbsp;</td>";
144
						}
145
						$c++;
146
					}
147
					echo "</tr>\n";
148
				}
149
				$p++;
150
			}
151
		    ?>
152
			</table>
153
                  </td>
154
                  <td class="listbg">
155 2792f9fe Scott Ullrich
                    <?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
156 719769d6 Seth Mos
                  </td>
157
		</tr>
158
			  <?php $i++; endforeach; ?>
159
160
	</table>
161
     </div>
162
    </td>
163
  </tr>
164
</table>
165
<?php include("fend.inc"); ?>
166
</body>
167
</html>