Project

General

Profile

Download (4.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
 * 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
$shortcut_section = "gateways";
43
include("head.inc");
44

    
45
/* active tabs */
46
$tab_array = array();
47
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
48
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
49
display_top_tabs($tab_array);
50
?>
51
<div class="panel panel-default">
52
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
53
	<div class="panel-body">
54

    
55
<div class="table-responsive">
56
	<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
57
		<thead>
58
			<tr>
59
				<th><?=gettext("Name"); ?></th>
60
				<th><?=gettext("Gateway"); ?></th>
61
				<th><?=gettext("Monitor"); ?></th>
62
				<th><?=gettext("RTT"); ?></th>
63
				<th><?=gettext("RTTsd"); ?></th>
64
				<th><?=gettext("Loss"); ?></th>
65
				<th><?=gettext("Status"); ?></th>
66
				<th><?=gettext("Description"); ?></th>
67
			</tr>
68
		</thead>
69
		<tbody>
70
<?php		foreach ($a_gateways as $gname => $gateway) {
71
?>
72
			<tr>
73
				<td>
74
					<?=htmlspecialchars($gateway['name']);?>
75
				</td>
76
				<td>
77
					<?=lookup_gateway_ip_by_name($gname);?>
78
				</td>
79
				<td>
80
<?php
81
					if ($gateways_status[$gname]) {
82
						echo $gateways_status[$gname]['monitorip'];
83
					} else {
84
						echo htmlspecialchars($gateway['monitorip']);
85
					}
86
?>
87
				</td>
88
				<td>
89
<?php
90
					if ($gateways_status[$gname]) {
91
						if (!isset($gateway['monitor_disable'])) {
92
							echo $gateways_status[$gname]['delay'];
93
						} 
94
					} else {
95
						echo gettext("Pending");
96
					}
97
?>
98
				</td>
99
				<td>
100
<?php
101
					if ($gateways_status[$gname]) {
102
						if (!isset($gateway['monitor_disable'])) {
103
							echo $gateways_status[$gname]['stddev'];
104
						}
105
					} else {
106
						echo gettext("Pending");
107
					}
108
?>
109
				</td>
110
				<td>
111
<?php
112
					if ($gateways_status[$gname]) {
113
						if (!isset($gateway['monitor_disable'])) {
114
							echo $gateways_status[$gname]['loss'];
115
						}
116
					} else {
117
						echo gettext("Pending");
118
					}
119
?>
120
				</td>
121
<?php
122
				if ($gateways_status[$gname]) {
123
					$status = $gateways_status[$gname];
124
					if (stristr($status['status'], "force_down")) {
125
						$online = gettext("Offline (forced)");
126
						$bgcolor = "bg-danger";
127
					} elseif (stristr($status['status'], "down")) {
128
						$online = gettext("Offline");
129
						$bgcolor = "bg-danger";
130
					} elseif (stristr($status['status'], "highloss")) {
131
						$online = gettext("Danger, Packetloss") . ': ' . $status['loss'];
132
						$bgcolor = "bg-danger";
133
					} elseif (stristr($status['status'], "loss")) {
134
						$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
135
						$bgcolor = "bg-warning";
136
					} elseif (stristr($status['status'], "highdelay")) {
137
						$online = gettext("Danger, Latency") . ': ' . $status['delay'];
138
						$bgcolor = "bg-danger";
139
					} elseif (stristr($status['status'], "delay")) {
140
						$online = gettext("Warning, Latency") . ': ' . $status['delay'];
141
						$bgcolor = "bg-warning";
142
					} elseif ($status['status'] == "none") {
143
						$online = gettext("Online");
144
						$bgcolor = "bg-success";
145
					}
146
				} else if (isset($gateway['monitor_disable'])) {
147
						$online = gettext("Online");
148
						$bgcolor = "bg-success";
149
				} else {
150
					$online = gettext("Pending");
151
					$bgcolor = "bg-info";
152
				}
153

    
154
				$lastchange = $gateways_status[$gname]['lastcheck'];
155

    
156
				if (!COLOR) {
157
				   $bgcolor = "";
158
				}
159
?>
160

    
161
				<td class="<?=$bgcolor?>">
162
					<strong><?=$online?></strong> <?php
163
					if (!empty($lastchange)) { ?>
164
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
165
<?php				} ?>
166
				</td>
167

    
168
				<td>
169
					<?=htmlspecialchars($gateway['descr']); ?>
170
				</td>
171
			</tr>
172
<?php	} ?>	<!-- End-of-foreach -->
173
		</tbody>
174
	</table>
175
</div>
176

    
177
	</div>
178
</div>
179

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