Project

General

Profile

Download (6.19 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 Electric Sheep Fencing, LLC
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
$shortcut_section = "gateways";
75
include("head.inc");
76

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

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

    
180
				$lastchange = $gateways_status[$gname]['lastcheck'];
181

    
182
				if (!COLOR) {
183
				   $bgcolor = "";
184
				}
185
?>
186

    
187
				<td class="<?=$bgcolor?>">
188
					<strong><?=$online?></strong> <?php
189
					if (!empty($lastchange)) { ?>
190
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
191
<?php				} ?>
192
				</td>
193

    
194
				<td>
195
					<?=htmlspecialchars($gateway['descr']); ?>
196
				</td>
197
			</tr>
198
<?php	} ?>	<!-- End-of-foreach -->
199
		</tbody>
200
	</table>
201
</div>
202

    
203
	</div>
204
</div>
205

    
206
<?php include("foot.inc"); ?>
(162-162/227)