Project

General

Profile

Download (4.65 KB) Statistics
| Branch: | Tag: | Revision:
1 ffd1a240 Seth Mos
<?php
2
/* $Id$ */
3
/*
4
	status_gateways.php
5 c7281770 Chris Buechler
	part of pfSense (https://www.pfsense.org/)
6 ffd1a240 Seth Mos
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 ffd1a240 Seth Mos
	All rights reserved.
10
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32 fff68385 sbeaver
/*
33 1d333258 Scott Ullrich
	pfSense_MODULE:	routing
34
*/
35 ffd1a240 Seth Mos
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-status-gateways
38
##|*NAME=Status: Gateways page
39
##|*DESCR=Allow access to the 'Status: Gateways' page.
40
##|*MATCH=status_gateways.php*
41
##|-PRIV
42
43 ffd1a240 Seth Mos
require("guiconfig.inc");
44
45 a023d257 sbeaver
define('COLOR', true);
46
define('LIGHTGREEN', '#90EE90');
47
define('LIGHTCORAL', '#F08080');
48
define('KHAKI',		 '#F0E68C');
49
define('LIGHTGRAY',	 '#D3D3D3');
50
define('WHITE',		 '#FFFFFF');
51
52 73e8bbe4 Seth Mos
$a_gateways = return_gateways_array();
53 ffd1a240 Seth Mos
$gateways_status = array();
54 68f291ff Ermal
$gateways_status = return_gateways_status(true);
55 ffd1a240 Seth Mos
56
$now = time();
57
$year = date("Y");
58
59 6c07db48 Phil Davis
$pgtitle = array(gettext("Status"), gettext("Gateways"));
60 b32dd0a6 jim-p
$shortcut_section = "gateways";
61 ffd1a240 Seth Mos
include("head.inc");
62
63 fff68385 sbeaver
/* active tabs */
64
$tab_array = array();
65
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
66
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
67
display_top_tabs($tab_array);
68 ffd1a240 Seth Mos
?>
69 fff68385 sbeaver
70 961ffe14 sbeaver
<div class="table-responsive">
71 fff68385 sbeaver
	<table class="table table-hover table-compact table-striped">
72 961ffe14 sbeaver
		<thead>
73
			<tr>
74 0843bc20 sbeaver
				<th><?=gettext("Name"); ?></th>
75
				<th><?=gettext("Gateway"); ?></th>
76
				<th><?=gettext("Monitor"); ?></th>
77
				<th><?=gettext("RTT"); ?></th>
78
				<th><?=gettext("Loss"); ?></th>
79
				<th><?=gettext("Status"); ?></th>
80
				<th><?=gettext("Description"); ?></th>
81 961ffe14 sbeaver
			</tr>
82
		</thead>
83
		<tbody>
84
<?php		foreach ($a_gateways as $gname => $gateway) {
85 fff68385 sbeaver
?>
86 961ffe14 sbeaver
			<tr>
87
				<td>
88
					<?=$gateway['name'];?>
89
				</td>
90
				<td>
91
					<?php echo lookup_gateway_ip_by_name($gname);?>
92
				</td>
93
				<td>
94
<?php				if ($gateways_status[$gname])
95
						echo $gateways_status[$gname]['monitorip'];
96
					else
97
						echo $gateway['monitorip'];
98 fff68385 sbeaver
?>
99 961ffe14 sbeaver
				</td>
100
				<td>
101 fff68385 sbeaver
<?php			if ($gateways_status[$gname])
102 961ffe14 sbeaver
					echo $gateways_status[$gname]['delay'];
103 fff68385 sbeaver
				else
104
					echo gettext("Pending");
105
?>
106 961ffe14 sbeaver
				<?php $counter++; ?>
107
				</td>
108
				<td>
109
<?php				if ($gateways_status[$gname])
110
						echo $gateways_status[$gname]['loss'];
111
					else
112
						echo gettext("Pending");
113
114
					$counter++;
115
?>
116
				</td>
117 fff68385 sbeaver
<?php
118 961ffe14 sbeaver
				if ($gateways_status[$gname]) {
119
					$status = $gateways_status[$gname];
120
					if (stristr($status['status'], "force_down")) {
121
						$online = gettext("Offline (forced)");
122
						$bgcolor = LIGHTCORAL;
123
					} elseif (stristr($status['status'], "down")) {
124
						$online = gettext("Offline");
125
						$bgcolor = LIGHTCORAL;
126
					} elseif (stristr($status['status'], "loss")) {
127
						$online = gettext("Warning, Packetloss").': '.$status['loss'];
128
						$bgcolor = KHAKI;
129
					} elseif (stristr($status['status'], "delay")) {
130
						$online = gettext("Warning, Latency").': '.$status['delay'];
131
						$bgcolor = KHAKI;
132
					} elseif ($status['status'] == "none") {
133
						$online = gettext("Online");
134
						$bgcolor = LIGHTGREEN;
135
					}
136
				} else if (isset($gateway['monitor_disable'])) {
137
						$online = gettext("Online");
138
						$bgcolor = LIGHTGREEN;
139
				} else {
140
					$online = gettext("Pending");
141
					$bgcolor = LIGHTGRAY;
142 a023d257 sbeaver
				}
143 961ffe14 sbeaver
144
				$lastchange = $gateways_status[$gname]['lastcheck'];
145
146
				if(!COLOR)
147
				   $bgcolor = WHITE;
148 fff68385 sbeaver
?>
149 a023d257 sbeaver
150 961ffe14 sbeaver
				<td bgcolor="<?=$bgcolor?>">
151
					<strong><?=$online?></strong> <?php
152
					if(!empty($lastchange)) { ?>
153
						<br /><i>Last checked <?=$lastchange?></i>
154
<?php				} ?>
155
				</td>
156
157
				<td>
158
					<?=$gateway['descr']; ?>
159
				</td>
160
			</tr>
161
<?php	} ?>	<!-- End-of-foreach -->
162
		</tbody>
163 fff68385 sbeaver
	</table>
164
</div>
165
166
<?php include("foot.inc"); ?>