1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_lb_vs.php
|
5
|
part of pfSense (https://www.pfsense.org/)
|
6
|
|
7
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8
|
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
|
/*
|
32
|
pfSense_BUILDER_BINARIES: /usr/local/sbin/relayctl
|
33
|
pfSense_MODULE: routing
|
34
|
*/
|
35
|
|
36
|
##|+PRIV
|
37
|
##|*IDENT=page-status-loadbalancer-virtualserver
|
38
|
##|*NAME=Status: Load Balancer: Virtual Server page
|
39
|
##|*DESCR=Allow access to the 'Status: Load Balancer: Virtual Server' page.
|
40
|
##|*MATCH=status_lb_vs.php*
|
41
|
##|-PRIV
|
42
|
|
43
|
require_once("guiconfig.inc");
|
44
|
require_once("vslb.inc");
|
45
|
|
46
|
if (!is_array($config['load_balancer']['lbpool'])) {
|
47
|
$config['load_balancer']['lbpool'] = array();
|
48
|
}
|
49
|
if (!is_array($config['load_balancer']['virtual_server'])) {
|
50
|
$config['load_balancer']['virtual_server'] = array();
|
51
|
}
|
52
|
$a_vs = &$config['load_balancer']['virtual_server'];
|
53
|
$a_pool = &$config['load_balancer']['lbpool'];
|
54
|
$rdr_a = get_lb_redirects();
|
55
|
|
56
|
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Virtual Server"));
|
57
|
include("head.inc");
|
58
|
|
59
|
?>
|
60
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
61
|
<?php include("fbegin.inc"); ?>
|
62
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status load balancer virtual servers">
|
63
|
<tr><td class="tabnavtbl">
|
64
|
<?php
|
65
|
/* active tabs */
|
66
|
$tab_array = array();
|
67
|
$tab_array[] = array(gettext("Pools"), false, "status_lb_pool.php");
|
68
|
$tab_array[] = array(gettext("Virtual Servers"), true, "status_lb_vs.php");
|
69
|
display_top_tabs($tab_array);
|
70
|
?>
|
71
|
</td></tr>
|
72
|
<tr>
|
73
|
<td>
|
74
|
<div id="mainarea">
|
75
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
76
|
<tr>
|
77
|
<td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
|
78
|
<td width="20%" class="listhdrr"><?=gettext("Address"); ?></td>
|
79
|
<td width="10%" class="listhdrr"><?=gettext("Servers"); ?></td>
|
80
|
<td width="25%" class="listhdrr"><?=gettext("Status"); ?></td>
|
81
|
<td width="25%" class="listhdr"><?=gettext("Description"); ?></td>
|
82
|
</tr>
|
83
|
<?php $i = 0; foreach ($a_vs as $vsent): ?>
|
84
|
<tr>
|
85
|
<td class="listlr">
|
86
|
<?=$vsent['name'];?>
|
87
|
</td>
|
88
|
<td class="listr" align="center" >
|
89
|
<?=$vsent['ipaddr']." : ".$vsent['port'];?>
|
90
|
<br />
|
91
|
</td>
|
92
|
<td class="listr" align="center" >
|
93
|
<table border="0" cellpadding="0" cellspacing="2" summary="servers">
|
94
|
<?php
|
95
|
foreach ($a_pool as $vipent) {
|
96
|
if ($vipent['name'] == $vsent['poolname']) {
|
97
|
foreach ((array) $vipent['servers'] as $server) {
|
98
|
print "<tr><td> {$server} </td></tr>";
|
99
|
}
|
100
|
}
|
101
|
}
|
102
|
?>
|
103
|
</table>
|
104
|
</td>
|
105
|
<?php
|
106
|
switch (trim($rdr_a[$vsent['name']]['status'])) {
|
107
|
case 'active':
|
108
|
$bgcolor = "#90EE90"; // lightgreen
|
109
|
$rdr_a[$vsent['name']]['status'] = "Active";
|
110
|
break;
|
111
|
case 'down':
|
112
|
$bgcolor = "#F08080"; // lightcoral
|
113
|
$rdr_a[$vsent['name']]['status'] = "Down";
|
114
|
break;
|
115
|
default:
|
116
|
$bgcolor = "#D3D3D3"; // lightgray
|
117
|
$rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
|
118
|
}
|
119
|
?>
|
120
|
<td class="listr nowrap">
|
121
|
<table border="0" cellpadding="3" cellspacing="2" summary="status">
|
122
|
<tr><td bgcolor="<?=$bgcolor?>"><?=$rdr_a[$vsent['name']]['status']?> </td></tr>
|
123
|
</table>
|
124
|
<?php
|
125
|
if (!empty($rdr_a[$vsent['name']]['total']))
|
126
|
echo "Total Sessions: {$rdr_a[$vsent['name']]['total']}\n";
|
127
|
if (!empty($rdr_a[$vsent['name']]['last']))
|
128
|
echo "<br />Last: {$rdr_a[$vsent['name']]['last']}\n";
|
129
|
if (!empty($rdr_a[$vsent['name']]['average']))
|
130
|
echo "<br />Average: {$rdr_a[$vsent['name']]['average']}\n";
|
131
|
?>
|
132
|
</td>
|
133
|
<td class="listbg" >
|
134
|
<?=$vsent['descr'];?>
|
135
|
</td>
|
136
|
</tr>
|
137
|
<?php $i++; endforeach; ?>
|
138
|
</table>
|
139
|
</div>
|
140
|
</td></tr>
|
141
|
</table>
|
142
|
|
143
|
<?php include("fend.inc"); ?>
|
144
|
</body>
|
145
|
</html>
|