Project

General

Profile

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

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

    
62
require_once("guiconfig.inc");
63

    
64
define('COLOR', true);
65

    
66
$a_gateways = return_gateways_array();
67
$gateways_status = array();
68
$gateways_status = return_gateways_status(true);
69

    
70
$now = time();
71
$year = date("Y");
72

    
73
$pgtitle = array(gettext("Status"), gettext("Gateways"), gettext("Gateways"));
74
$pglinks = array("", "@self", "@self");
75
$shortcut_section = "gateways";
76
include("head.inc");
77

    
78
/* active tabs */
79
$tab_array = array();
80
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
81
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
82
display_top_tabs($tab_array);
83
?>
84
<div class="panel panel-default">
85
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
86
	<div class="panel-body">
87

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

    
193
				$lastchange = $gateways_status[$gname]['lastcheck'];
194

    
195
				if (!COLOR) {
196
				   $bgcolor = "";
197
				}
198
?>
199

    
200
				<td class="<?=$bgcolor?>">
201
					<strong><?=$online?></strong> <?php
202
					if (!empty($lastchange)) { ?>
203
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
204
<?php				} ?>
205
				</td>
206

    
207
				<td>
208
					<?=htmlspecialchars($gateway['descr']); ?>
209
				</td>
210
			</tr>
211
<?php	} ?>	<!-- End-of-foreach -->
212
		</tbody>
213
	</table>
214
</div>
215

    
216
	</div>
217
</div>
218

    
219
<?php include("foot.inc"); ?>
(160-160/225)