Project

General

Profile

Download (4.53 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
 * 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'], "loss")) {
131
						$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
132
						$bgcolor = "bg-warning";
133
					} elseif (stristr($status['status'], "delay")) {
134
						$online = gettext("Warning, Latency") . ': ' . $status['delay'];
135
						$bgcolor = "bg-warning";
136
					} elseif ($status['status'] == "none") {
137
						$online = gettext("Online");
138
						$bgcolor = "bg-success";
139
					}
140
				} else if (isset($gateway['monitor_disable'])) {
141
						$online = gettext("Online");
142
						$bgcolor = "bg-success";
143
				} else {
144
					$online = gettext("Pending");
145
					$bgcolor = "bg-info";
146
				}
147

    
148
				$lastchange = $gateways_status[$gname]['lastcheck'];
149

    
150
				if (!COLOR) {
151
				   $bgcolor = "";
152
				}
153
?>
154

    
155
				<td class="<?=$bgcolor?>">
156
					<strong><?=$online?></strong> <?php
157
					if (!empty($lastchange)) { ?>
158
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
159
<?php				} ?>
160
				</td>
161

    
162
				<td>
163
					<?=htmlspecialchars($gateway['descr']); ?>
164
				</td>
165
			</tr>
166
<?php	} ?>	<!-- End-of-foreach -->
167
		</tbody>
168
	</table>
169
</div>
170

    
171
	</div>
172
</div>
173

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