Project

General

Profile

Download (6.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_gateways.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2010 Seth Mos <seth.mos@dds.nl>
8
 *
9
 *	Redistribution and use in source and binary forms, with or without modification,
10
 *	are permitted provided that the following conditions are met:
11
 *
12
 *	1. Redistributions of source code must retain the above copyright notice,
13
 *		this list of conditions and the following disclaimer.
14
 *
15
 *	2. Redistributions in binary form must reproduce the above copyright
16
 *		notice, this list of conditions and the following disclaimer in
17
 *		the documentation and/or other materials provided with the
18
 *		distribution.
19
 *
20
 *	3. All advertising materials mentioning features or use of this software
21
 *		must display the following acknowledgment:
22
 *		"This product includes software developed by the pfSense Project
23
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
24
 *
25
 *	4. The names "pfSense" and "pfSense Project" must not be used to
26
 *		 endorse or promote products derived from this software without
27
 *		 prior written permission. For written permission, please contact
28
 *		 coreteam@pfsense.org.
29
 *
30
 *	5. Products derived from this software may not be called "pfSense"
31
 *		nor may "pfSense" appear in their names without prior written
32
 *		permission of the Electric Sheep Fencing, LLC.
33
 *
34
 *	6. Redistributions of any form whatsoever must retain the following
35
 *		acknowledgment:
36
 *
37
 *	"This product includes software developed by the pfSense Project
38
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
52
 *
53
 *	====================================================================
54
 *
55
 */
56

    
57
##|+PRIV
58
##|*IDENT=page-status-gateways
59
##|*NAME=Status: Gateways
60
##|*DESCR=Allow access to the 'Status: Gateways' page.
61
##|*MATCH=status_gateways.php*
62
##|-PRIV
63

    
64
require("guiconfig.inc");
65

    
66
define('COLOR', true);
67
define('LIGHTGREEN', '#90EE90');
68
define('LIGHTCORAL', '#F08080');
69
define('KHAKI',		 '#F0E68C');
70
define('LIGHTGRAY',	 '#D3D3D3');
71
define('WHITE',		 '#FFFFFF');
72

    
73
$a_gateways = return_gateways_array();
74
$gateways_status = array();
75
$gateways_status = return_gateways_status(true);
76

    
77
$now = time();
78
$year = date("Y");
79

    
80
$pgtitle = array(gettext("Status"), gettext("Gateways"));
81
$shortcut_section = "gateways";
82
include("head.inc");
83

    
84
/* active tabs */
85
$tab_array = array();
86
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
87
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
88
display_top_tabs($tab_array);
89
?>
90
<div class="panel panel-default">
91
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
92
	<div class="panel-body">
93

    
94
<div class="table-responsive">
95
	<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
96
		<thead>
97
			<tr>
98
				<th><?=gettext("Name"); ?></th>
99
				<th><?=gettext("Gateway"); ?></th>
100
				<th><?=gettext("Monitor"); ?></th>
101
				<th><?=gettext("RTT"); ?></th>
102
				<th><?=gettext("RTTsd"); ?></th>
103
				<th><?=gettext("Loss"); ?></th>
104
				<th><?=gettext("Status"); ?></th>
105
				<th><?=gettext("Description"); ?></th>
106
			</tr>
107
		</thead>
108
		<tbody>
109
<?php		foreach ($a_gateways as $gname => $gateway) {
110
?>
111
			<tr>
112
				<td>
113
					<?=htmlspecialchars($gateway['name']);?>
114
				</td>
115
				<td>
116
					<?=lookup_gateway_ip_by_name($gname);?>
117
				</td>
118
				<td>
119
<?php
120
					if ($gateways_status[$gname]) {
121
						echo $gateways_status[$gname]['monitorip'];
122
					} else {
123
						echo htmlspecialchars($gateway['monitorip']);
124
					}
125
?>
126
				</td>
127
				<td>
128
<?php
129
					if ($gateways_status[$gname]) {
130
						if (!isset($gateway['monitor_disable'])) {
131
							echo $gateways_status[$gname]['delay'];
132
						} 
133
					} else {
134
						echo gettext("Pending");
135
					}
136
?>
137
				</td>
138
				<td>
139
<?php
140
					if ($gateways_status[$gname]) {
141
						if (!isset($gateway['monitor_disable'])) {
142
							echo $gateways_status[$gname]['stddev'];
143
						}
144
					} else {
145
						echo gettext("Pending");
146
					}
147
?>
148
				</td>
149
				<td>
150
<?php
151
					if ($gateways_status[$gname]) {
152
						if (!isset($gateway['monitor_disable'])) {
153
							echo $gateways_status[$gname]['loss'];
154
						}
155
					} else {
156
						echo gettext("Pending");
157
					}
158
?>
159
				</td>
160
<?php
161
				if ($gateways_status[$gname]) {
162
					$status = $gateways_status[$gname];
163
					if (stristr($status['status'], "force_down")) {
164
						$online = gettext("Offline (forced)");
165
						$bgcolor = LIGHTCORAL;
166
					} elseif (stristr($status['status'], "down")) {
167
						$online = gettext("Offline");
168
						$bgcolor = LIGHTCORAL;
169
					} elseif (stristr($status['status'], "loss")) {
170
						$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
171
						$bgcolor = KHAKI;
172
					} elseif (stristr($status['status'], "delay")) {
173
						$online = gettext("Warning, Latency") . ': ' . $status['delay'];
174
						$bgcolor = KHAKI;
175
					} elseif ($status['status'] == "none") {
176
						$online = gettext("Online");
177
						$bgcolor = LIGHTGREEN;
178
					}
179
				} else if (isset($gateway['monitor_disable'])) {
180
						$online = gettext("Online");
181
						$bgcolor = LIGHTGREEN;
182
				} else {
183
					$online = gettext("Pending");
184
					$bgcolor = LIGHTGRAY;
185
				}
186

    
187
				$lastchange = $gateways_status[$gname]['lastcheck'];
188

    
189
				if (!COLOR) {
190
				   $bgcolor = WHITE;
191
				}
192
?>
193

    
194
				<td style="background-color:<?=$bgcolor?>">
195
					<strong><?=$online?></strong> <?php
196
					if (!empty($lastchange)) { ?>
197
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
198
<?php				} ?>
199
				</td>
200

    
201
				<td>
202
					<?=htmlspecialchars($gateway['descr']); ?>
203
				</td>
204
			</tr>
205
<?php	} ?>	<!-- End-of-foreach -->
206
		</tbody>
207
	</table>
208
</div>
209

    
210
	</div>
211
</div>
212

    
213
<?php include("foot.inc"); ?>
(160-160/229)