Project

General

Profile

Download (4.65 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_gateways.php
5
	part of pfSense (https://www.pfsense.org/)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	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
/*
33
	pfSense_MODULE:	routing
34
*/
35

    
36
##|+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
require("guiconfig.inc");
44

    
45
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
$a_gateways = return_gateways_array();
53
$gateways_status = array();
54
$gateways_status = return_gateways_status(true);
55

    
56
$now = time();
57
$year = date("Y");
58

    
59
$pgtitle = array(gettext("Status"), gettext("Gateways"));
60
$shortcut_section = "gateways";
61
include("head.inc");
62

    
63
/* 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
?>
69

    
70
<div class="table-responsive">
71
	<table class="table table-hover table-compact table-striped">
72
		<thead>
73
			<tr>
74
				<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
			</tr>
82
		</thead>
83
		<tbody>
84
<?php		foreach ($a_gateways as $gname => $gateway) {
85
?>
86
			<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
?>
99
				</td>
100
				<td>
101
<?php			if ($gateways_status[$gname])
102
					echo $gateways_status[$gname]['delay'];
103
				else
104
					echo gettext("Pending");
105
?>
106
				<?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
<?php
118
				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
				}
143

    
144
				$lastchange = $gateways_status[$gname]['lastcheck'];
145

    
146
				if(!COLOR)
147
				   $bgcolor = WHITE;
148
?>
149

    
150
				<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
	</table>
164
</div>
165

    
166
<?php include("foot.inc"); ?>
(172-172/235)