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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
* you may not use this file except in compliance with the License.
|
12
|
* You may obtain a copy of the License at
|
13
|
*
|
14
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15
|
*
|
16
|
* Unless required by applicable law or agreed to in writing, software
|
17
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
* See the License for the specific language governing permissions and
|
20
|
* limitations under the License.
|
21
|
*/
|
22
|
|
23
|
##|+PRIV
|
24
|
##|*IDENT=page-status-gateways
|
25
|
##|*NAME=Status: Gateways
|
26
|
##|*DESCR=Allow access to the 'Status: Gateways' page.
|
27
|
##|*MATCH=status_gateways.php*
|
28
|
##|-PRIV
|
29
|
|
30
|
require_once("guiconfig.inc");
|
31
|
|
32
|
define('COLOR', true);
|
33
|
|
34
|
$a_gateways = return_gateways_array();
|
35
|
$gateways_status = array();
|
36
|
$gateways_status = return_gateways_status(true);
|
37
|
|
38
|
$now = time();
|
39
|
$year = date("Y");
|
40
|
|
41
|
$pgtitle = array(gettext("Status"), gettext("Gateways"), gettext("Gateways"));
|
42
|
$pglinks = array("", "@self", "@self");
|
43
|
$shortcut_section = "gateways";
|
44
|
include("head.inc");
|
45
|
|
46
|
/* active tabs */
|
47
|
$tab_array = array();
|
48
|
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
|
49
|
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
|
50
|
display_top_tabs($tab_array);
|
51
|
?>
|
52
|
<div class="panel panel-default">
|
53
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
|
54
|
<div class="panel-body">
|
55
|
|
56
|
<div class="table-responsive">
|
57
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
58
|
<thead>
|
59
|
<tr>
|
60
|
<th><?=gettext("Name"); ?></th>
|
61
|
<th><?=gettext("Gateway"); ?></th>
|
62
|
<th><?=gettext("Monitor"); ?></th>
|
63
|
<th><?=gettext("RTT"); ?></th>
|
64
|
<th><?=gettext("RTTsd"); ?></th>
|
65
|
<th><?=gettext("Loss"); ?></th>
|
66
|
<th><?=gettext("Status"); ?></th>
|
67
|
<th><?=gettext("Description"); ?></th>
|
68
|
</tr>
|
69
|
</thead>
|
70
|
<tbody>
|
71
|
<?php foreach ($a_gateways as $gname => $gateway) {
|
72
|
?>
|
73
|
<tr>
|
74
|
<td>
|
75
|
<?=htmlspecialchars($gateway['name']);?>
|
76
|
</td>
|
77
|
<td>
|
78
|
<?=lookup_gateway_ip_by_name($gname);?>
|
79
|
</td>
|
80
|
<td>
|
81
|
<?php
|
82
|
if ($gateways_status[$gname]) {
|
83
|
echo $gateways_status[$gname]['monitorip'];
|
84
|
} else {
|
85
|
echo htmlspecialchars($gateway['monitorip']);
|
86
|
}
|
87
|
?>
|
88
|
</td>
|
89
|
<td>
|
90
|
<?php
|
91
|
if ($gateways_status[$gname]) {
|
92
|
if (!isset($gateway['monitor_disable'])) {
|
93
|
echo $gateways_status[$gname]['delay'];
|
94
|
}
|
95
|
} else {
|
96
|
echo gettext("Pending");
|
97
|
}
|
98
|
?>
|
99
|
</td>
|
100
|
<td>
|
101
|
<?php
|
102
|
if ($gateways_status[$gname]) {
|
103
|
if (!isset($gateway['monitor_disable'])) {
|
104
|
echo $gateways_status[$gname]['stddev'];
|
105
|
}
|
106
|
} else {
|
107
|
echo gettext("Pending");
|
108
|
}
|
109
|
?>
|
110
|
</td>
|
111
|
<td>
|
112
|
<?php
|
113
|
if ($gateways_status[$gname]) {
|
114
|
if (!isset($gateway['monitor_disable'])) {
|
115
|
echo $gateways_status[$gname]['loss'];
|
116
|
}
|
117
|
} else {
|
118
|
echo gettext("Pending");
|
119
|
}
|
120
|
?>
|
121
|
</td>
|
122
|
<?php
|
123
|
if ($gateways_status[$gname]) {
|
124
|
$status = $gateways_status[$gname];
|
125
|
if (stristr($status['status'], "force_down")) {
|
126
|
$online = gettext("Offline (forced)");
|
127
|
$bgcolor = "bg-danger";
|
128
|
} elseif (stristr($status['status'], "down")) {
|
129
|
$online = gettext("Offline");
|
130
|
$bgcolor = "bg-danger";
|
131
|
} elseif (stristr($status['status'], "highloss")) {
|
132
|
$online = gettext("Danger, Packetloss") . ': ' . $status['loss'];
|
133
|
$bgcolor = "bg-danger";
|
134
|
} elseif (stristr($status['status'], "loss")) {
|
135
|
$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
|
136
|
$bgcolor = "bg-warning";
|
137
|
} elseif (stristr($status['status'], "highdelay")) {
|
138
|
$online = gettext("Danger, Latency") . ': ' . $status['delay'];
|
139
|
$bgcolor = "bg-danger";
|
140
|
} elseif (stristr($status['status'], "delay")) {
|
141
|
$online = gettext("Warning, Latency") . ': ' . $status['delay'];
|
142
|
$bgcolor = "bg-warning";
|
143
|
} elseif ($status['status'] == "none") {
|
144
|
if ($status['monitor_disable'] || ($status['monitorip'] == "none")) {
|
145
|
$online = gettext("Online (unmonitored)");
|
146
|
} else {
|
147
|
$online = gettext("Online");
|
148
|
}
|
149
|
$bgcolor = "bg-success";
|
150
|
}
|
151
|
} else if (isset($gateway['monitor_disable'])) {
|
152
|
// Note: return_gateways_status() always returns an array entry for all gateways,
|
153
|
// so this "else if" never happens.
|
154
|
$online = gettext("Online (unmonitored)");
|
155
|
$bgcolor = "bg-success";
|
156
|
} else {
|
157
|
$online = gettext("Pending");
|
158
|
$bgcolor = "bg-info";
|
159
|
}
|
160
|
|
161
|
$lastchange = $gateways_status[$gname]['lastcheck'];
|
162
|
|
163
|
if (!COLOR) {
|
164
|
$bgcolor = "";
|
165
|
}
|
166
|
?>
|
167
|
|
168
|
<td class="<?=$bgcolor?>">
|
169
|
<strong><?=$online?></strong> <?php
|
170
|
if (!empty($lastchange)) { ?>
|
171
|
<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
|
172
|
<?php } ?>
|
173
|
</td>
|
174
|
|
175
|
<td>
|
176
|
<?=htmlspecialchars($gateway['descr']); ?>
|
177
|
</td>
|
178
|
</tr>
|
179
|
<?php } ?> <!-- End-of-foreach -->
|
180
|
</tbody>
|
181
|
</table>
|
182
|
</div>
|
183
|
|
184
|
</div>
|
185
|
</div>
|
186
|
|
187
|
<?php include("foot.inc"); ?>
|