Project

General

Profile

Download (5.64 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_gateway_groups.php
5
	part of pfSense (https://www.pfsense.org)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	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
/*	
33
	pfSense_MODULE:	routing
34
*/
35

    
36
##|+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
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
$changedesc = gettext("Gateway Groups") . ": ";
50

    
51
$gateways_status = return_gateways_status();
52

    
53
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
54
$shortcut_section = "gateway-groups";
55
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
			$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
67
			$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
68
			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
                  <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
		</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
			ksort($priorities);
99

    
100
			echo "<tr>";
101
			foreach($priorities as $number => $tier) {
102
				echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>";
103
			}
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
			ksort($priority_arr);
113
			$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
						$monitor = lookup_gateway_monitor_ip_by_name($member);
122
						if($p == $c) {
123
							$status = $gateways_status[$monitor]['status'];
124
							if (stristr($status, "down")) {
125
                                        			$online = gettext("Offline");
126
                                        			$bgcolor = "#F08080";  // lightcoral
127
                                			} elseif (stristr($status, "loss")) {
128
                                        			$online = gettext("Warning, Packetloss");
129
                                        			$bgcolor = "#F0E68C";  // khaki
130
                                			} elseif (stristr($status, "delay")) {
131
                                        			$online = gettext("Warning, Latency");
132
                                        			$bgcolor = "#F0E68C";  // khaki
133
                                			} elseif ($status == "none") {
134
                                        			$online = gettext("Online");
135
                                        			$bgcolor = "#90EE90";  // lightgreen
136
                                			} else {
137
								$online = gettext("Gathering data");
138
								$bgcolor = "#ADD8E6";  // lightblue
139
							}
140
							echo "<td bgcolor='$bgcolor'>&nbsp;". htmlspecialchars($member) .", $online&nbsp;</td>";
141
						} 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
                    <?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
155
                  </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>
(188-188/256)