Project

General

Profile

Download (6.51 KB) Statistics
| Branch: | Tag: | Revision:
1 ffd1a240 Seth Mos
<?php
2
/*
3 aaec5634 Renato Botelho
 * status_gateways.php
4 191cb31d Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
8
 * All rights reserved.
9 191cb31d Stephen Beaver
 *
10 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions are met:
12 191cb31d Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
14
 *    this list of conditions and the following disclaimer.
15 191cb31d Stephen Beaver
 *
16 aaec5634 Renato Botelho
 * 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 191cb31d Stephen Beaver
 *
21 aaec5634 Renato Botelho
 * 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 191cb31d Stephen Beaver
 *
26 aaec5634 Renato Botelho
 * 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 191cb31d Stephen Beaver
 *
31 aaec5634 Renato Botelho
 * 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 191cb31d Stephen Beaver
 *
35 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
36
 *    acknowledgment:
37 191cb31d Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
39
 * for use in the pfSense software distribution (http://www.pfsense.org/).
40 191cb31d Stephen Beaver
 *
41 aaec5634 Renato Botelho
 * 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 191cb31d Stephen Beaver
 */
54 ffd1a240 Seth Mos
55 6b07c15a Matthew Grooms
##|+PRIV
56
##|*IDENT=page-status-gateways
57 5230f468 jim-p
##|*NAME=Status: Gateways
58 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: Gateways' page.
59
##|*MATCH=status_gateways.php*
60
##|-PRIV
61
62 aceaf18c Phil Davis
require_once("guiconfig.inc");
63 ffd1a240 Seth Mos
64 a023d257 sbeaver
define('COLOR', true);
65
66 73e8bbe4 Seth Mos
$a_gateways = return_gateways_array();
67 ffd1a240 Seth Mos
$gateways_status = array();
68 68f291ff Ermal
$gateways_status = return_gateways_status(true);
69 ffd1a240 Seth Mos
70
$now = time();
71
$year = date("Y");
72
73 f4741421 k-paulius
$pgtitle = array(gettext("Status"), gettext("Gateways"), gettext("Gateways"));
74 b32dd0a6 jim-p
$shortcut_section = "gateways";
75 ffd1a240 Seth Mos
include("head.inc");
76
77 fff68385 sbeaver
/* 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 ffd1a240 Seth Mos
?>
83 ac950976 Colin Fleming
<div class="panel panel-default">
84
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
85
	<div class="panel-body">
86 fff68385 sbeaver
87 961ffe14 sbeaver
<div class="table-responsive">
88 10fe1eb5 Stephen Beaver
	<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
89 961ffe14 sbeaver
		<thead>
90
			<tr>
91 0843bc20 sbeaver
				<th><?=gettext("Name"); ?></th>
92
				<th><?=gettext("Gateway"); ?></th>
93
				<th><?=gettext("Monitor"); ?></th>
94
				<th><?=gettext("RTT"); ?></th>
95 b90e4de2 Denny Page
				<th><?=gettext("RTTsd"); ?></th>
96 0843bc20 sbeaver
				<th><?=gettext("Loss"); ?></th>
97
				<th><?=gettext("Status"); ?></th>
98
				<th><?=gettext("Description"); ?></th>
99 961ffe14 sbeaver
			</tr>
100
		</thead>
101
		<tbody>
102
<?php		foreach ($a_gateways as $gname => $gateway) {
103 fff68385 sbeaver
?>
104 961ffe14 sbeaver
			<tr>
105
				<td>
106 8ebf884f jim-p
					<?=htmlspecialchars($gateway['name']);?>
107 961ffe14 sbeaver
				</td>
108
				<td>
109 5c0ab3cd NewEraCracker
					<?=lookup_gateway_ip_by_name($gname);?>
110 961ffe14 sbeaver
				</td>
111
				<td>
112 3e0a4bbb Phil Davis
<?php
113
					if ($gateways_status[$gname]) {
114 961ffe14 sbeaver
						echo $gateways_status[$gname]['monitorip'];
115 3e0a4bbb Phil Davis
					} else {
116 8ebf884f jim-p
						echo htmlspecialchars($gateway['monitorip']);
117 3e0a4bbb Phil Davis
					}
118 fff68385 sbeaver
?>
119 961ffe14 sbeaver
				</td>
120
				<td>
121 3e0a4bbb Phil Davis
<?php
122
					if ($gateways_status[$gname]) {
123 7ebc7c51 Chris Buechler
						if (!isset($gateway['monitor_disable'])) {
124
							echo $gateways_status[$gname]['delay'];
125
						} 
126 3e0a4bbb Phil Davis
					} else {
127
						echo gettext("Pending");
128
					}
129 fff68385 sbeaver
?>
130 961ffe14 sbeaver
				</td>
131
				<td>
132 b90e4de2 Denny Page
<?php
133
					if ($gateways_status[$gname]) {
134 7ebc7c51 Chris Buechler
						if (!isset($gateway['monitor_disable'])) {
135
							echo $gateways_status[$gname]['stddev'];
136
						}
137 b90e4de2 Denny Page
					} else {
138
						echo gettext("Pending");
139
					}
140
?>
141
				</td>
142
				<td>
143 3e0a4bbb Phil Davis
<?php
144
					if ($gateways_status[$gname]) {
145 7ebc7c51 Chris Buechler
						if (!isset($gateway['monitor_disable'])) {
146
							echo $gateways_status[$gname]['loss'];
147
						}
148 3e0a4bbb Phil Davis
					} else {
149 961ffe14 sbeaver
						echo gettext("Pending");
150 3e0a4bbb Phil Davis
					}
151 961ffe14 sbeaver
?>
152
				</td>
153 fff68385 sbeaver
<?php
154 961ffe14 sbeaver
				if ($gateways_status[$gname]) {
155
					$status = $gateways_status[$gname];
156
					if (stristr($status['status'], "force_down")) {
157
						$online = gettext("Offline (forced)");
158 5a331169 Jared Dillard
						$bgcolor = "bg-danger";
159 961ffe14 sbeaver
					} elseif (stristr($status['status'], "down")) {
160
						$online = gettext("Offline");
161 5a331169 Jared Dillard
						$bgcolor = "bg-danger";
162 bb0a0bb2 Phil Davis
					} elseif (stristr($status['status'], "highloss")) {
163
						$online = gettext("Danger, Packetloss") . ': ' . $status['loss'];
164
						$bgcolor = "bg-danger";
165 961ffe14 sbeaver
					} elseif (stristr($status['status'], "loss")) {
166 98128ad6 Phil Davis
						$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
167 5a331169 Jared Dillard
						$bgcolor = "bg-warning";
168 bb0a0bb2 Phil Davis
					} elseif (stristr($status['status'], "highdelay")) {
169
						$online = gettext("Danger, Latency") . ': ' . $status['delay'];
170
						$bgcolor = "bg-danger";
171 961ffe14 sbeaver
					} elseif (stristr($status['status'], "delay")) {
172 98128ad6 Phil Davis
						$online = gettext("Warning, Latency") . ': ' . $status['delay'];
173 5a331169 Jared Dillard
						$bgcolor = "bg-warning";
174 961ffe14 sbeaver
					} elseif ($status['status'] == "none") {
175
						$online = gettext("Online");
176 5a331169 Jared Dillard
						$bgcolor = "bg-success";
177 961ffe14 sbeaver
					}
178
				} else if (isset($gateway['monitor_disable'])) {
179
						$online = gettext("Online");
180 5a331169 Jared Dillard
						$bgcolor = "bg-success";
181 961ffe14 sbeaver
				} else {
182
					$online = gettext("Pending");
183 5a331169 Jared Dillard
					$bgcolor = "bg-info";
184 a023d257 sbeaver
				}
185 961ffe14 sbeaver
186
				$lastchange = $gateways_status[$gname]['lastcheck'];
187
188 3e0a4bbb Phil Davis
				if (!COLOR) {
189 5a331169 Jared Dillard
				   $bgcolor = "";
190 3e0a4bbb Phil Davis
				}
191 fff68385 sbeaver
?>
192 a023d257 sbeaver
193 5a331169 Jared Dillard
				<td class="<?=$bgcolor?>">
194 961ffe14 sbeaver
					<strong><?=$online?></strong> <?php
195 3e0a4bbb Phil Davis
					if (!empty($lastchange)) { ?>
196 98128ad6 Phil Davis
						<br /><i><?=gettext("Last checked")?> <?=$lastchange?></i>
197 961ffe14 sbeaver
<?php				} ?>
198
				</td>
199
200
				<td>
201 8ebf884f jim-p
					<?=htmlspecialchars($gateway['descr']); ?>
202 961ffe14 sbeaver
				</td>
203
			</tr>
204
<?php	} ?>	<!-- End-of-foreach -->
205
		</tbody>
206 fff68385 sbeaver
	</table>
207
</div>
208
209 ac950976 Colin Fleming
	</div>
210
</div>
211
212 fff68385 sbeaver
<?php include("foot.inc"); ?>