Project

General

Profile

Download (5.37 KB) Statistics
| Branch: | Tag: | Revision:
1 ffd1a240 Seth Mos
<?php
2
/* $Id$ */
3
/*
4
	status_gateways.php
5
	part of pfSense (http://www.pfsense.com/)
6
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 ffd1a240 Seth Mos
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 1d333258 Scott Ullrich
/*	
32
	pfSense_MODULE:	routing
33
*/
34 ffd1a240 Seth Mos
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-status-gateways
37
##|*NAME=Status: Gateways page
38
##|*DESCR=Allow access to the 'Status: Gateways' page.
39
##|*MATCH=status_gateways.php*
40
##|-PRIV
41
42 ffd1a240 Seth Mos
require("guiconfig.inc");
43
44 73e8bbe4 Seth Mos
$a_gateways = return_gateways_array();
45 ffd1a240 Seth Mos
$gateways_status = array();
46 68f291ff Ermal
$gateways_status = return_gateways_status(true);
47 ffd1a240 Seth Mos
48
$now = time();
49
$year = date("Y");
50
51 b8e27fbb Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Gateways"));
52 ffd1a240 Seth Mos
include("head.inc");
53
54
?>
55
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
56
<?php include("fbegin.inc"); ?>
57
<table width="100%" border="0" cellpadding="0" cellspacing="0">
58
  <tr><td class="tabnavtbl">
59
  <?php
60
        /* active tabs */
61
        $tab_array = array();
62 b8e27fbb Carlos Eduardo Ramos
        $tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
63
        $tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
64 ffd1a240 Seth Mos
        display_top_tabs($tab_array);
65
  ?>
66
  </td></tr>
67
  <tr>
68
    <td>
69
	<div id="mainarea">
70 3473bb6a Scott Ullrich
              <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
71 ffd1a240 Seth Mos
                <tr>
72 b8e27fbb Carlos Eduardo Ramos
                  <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
73
                  <td width="10%" class="listhdrr"><?=gettext("Gateway"); ?></td>
74
                  <td width="10%" class="listhdrr"><?=gettext("Monitor"); ?></td>
75 fc4fa6de jim-p
                  <td width="10%" class="listhdrr"><?=gettext("RTT"); ?></td>
76
                  <td width="10%" class="listhdrr"><?=gettext("Loss"); ?></td>
77
                  <td width="20%" class="listhdrr"><?=gettext("Status"); ?></td>
78 b8e27fbb Carlos Eduardo Ramos
                  <td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
79 68f291ff Ermal
		</tr>
80
		  <?php foreach ($a_gateways as $gname => $gateway) {
81 9a21b547 Seth Mos
			?>
82 ffd1a240 Seth Mos
                <tr>
83
                  <td class="listlr">
84 6f77aca5 Ermal
				<?=$gateway['name'];?>
85 ffd1a240 Seth Mos
                  </td>
86
                  <td class="listr" align="center" >
87 68f291ff Ermal
                                <?php echo lookup_gateway_ip_by_name($gname);?>
88 ffd1a240 Seth Mos
                  </td>
89
                  <td class="listr" align="center" >
90 68f291ff Ermal
                                <?php 	if ($gateways_status[$gname]) 
91
						echo $gateways_status[$gname]['monitorip'];
92
					else
93
						echo $gateway['monitorip'];
94
				?>
95 ffd1a240 Seth Mos
                  </td>
96 fc4fa6de jim-p
		<td class="listr" align="center">
97
		<?php	if ($gateways_status[$gname])
98
				echo $gateways_status[$gname]['delay'];
99
			else
100
				echo gettext("Gathering data");
101
		?>
102
				<?php $counter++; ?>
103
		</td>
104
		<td class="listr" align="center">
105
		<?php	if ($gateways_status[$gname])
106
				echo $gateways_status[$gname]['loss'];
107
			else
108
				echo gettext("Gathering data");
109
		?>
110
				<?php $counter++; ?>
111
		</td>
112 ffd1a240 Seth Mos
                  <td class="listr" >
113
			<table border="0" cellpadding="0" cellspacing="2">
114
                        <?php
115 68f291ff Ermal
				if ($gateways_status[$gname]) {
116
					$status = $gateways_status[$gname];
117
					if (stristr($status['status'], "down")) {
118
						$online = gettext("Offline");
119
						$bgcolor = "lightcoral";
120
					} elseif (stristr($status['status'], "loss")) {
121
						$online = gettext("Warning, Packetloss");
122
						$bgcolor = "khaki";
123
					} elseif (stristr($status['status'], "delay")) {
124
						$online = gettext("Warning, Latency");
125
						$bgcolor = "khaki";
126
					} elseif ($status['status'] == "none") {
127
						$online = gettext("Online");
128
						$bgcolor = "lightgreen";
129
					}
130 db07cc25 Ermal
				} else if (isset($gateway['monitor_disable'])) {
131
						$online = gettext("Online");
132
						$bgcolor = "lightgreen";
133 68f291ff Ermal
				} else {
134 7ec17767 Ermal
					$online = gettext("Gathering data");
135 68f291ff Ermal
					$bgcolor = "lightgray";
136 ffd1a240 Seth Mos
				}
137 beb7b814 Ermal
				echo "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
138
				$lastchange = $gateway['lastcheck'];
139 73e8bbe4 Seth Mos
				if(!empty($lastchange)) {
140
					$lastchange = explode(" ", $lastchange);
141
					array_shift($lastchange);
142
					array_shift($lastchange);
143
					$lastchange = implode(" ", $lastchange);
144 b8e27fbb Carlos Eduardo Ramos
					printf(gettext("Last check %s"), $lastchange);
145 73e8bbe4 Seth Mos
				}
146 beb7b814 Ermal
				echo "</td></tr>";
147 ffd1a240 Seth Mos
                        ?>
148
			</table>
149
                  </td>
150 68f291ff Ermal
		  <td class="listbg"> <?=$gateway['descr']; ?></td>
151 ffd1a240 Seth Mos
                </tr>
152 9a21b547 Seth Mos
		<?php } ?>
153 ffd1a240 Seth Mos
              </table>
154
	   </div>
155
	</table>
156
157
<?php include("fend.inc"); ?>
158
</body>
159
</html>