Project

General

Profile

Download (4.45 KB) Statistics
| Branch: | Tag: | Revision:
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
	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_BUILDER_BINARIES:	/usr/local/sbin/relayctl
34
	pfSense_MODULE: routing
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-status-loadbalancer-virtualserver
39
##|*NAME=Status: Load Balancer: Virtual Server page
40
##|*DESCR=Allow access to the 'Status: Load Balancer: Virtual Server' page.
41
##|*MATCH=status_lb_vs.php*
42
##|-PRIV
43

    
44
define('COLOR', true);
45
define('LIGHTGREEN', '#90EE90');
46
define('LIGHTCORAL', '#F08080');
47
define('KHAKI',		 '#F0E68C');
48
define('LIGHTGRAY',	 '#D3D3D3');
49
define('WHITE',		 '#FFFFFF');
50

    
51
require_once("guiconfig.inc");
52
require_once("vslb.inc");
53

    
54
if (!is_array($config['load_balancer']['lbpool'])) {
55
	$config['load_balancer']['lbpool'] = array();
56
}
57
if (!is_array($config['load_balancer']['virtual_server'])) {
58
	$config['load_balancer']['virtual_server'] = array();
59
}
60
$a_vs = &$config['load_balancer']['virtual_server'];
61
$a_pool = &$config['load_balancer']['lbpool'];
62
$rdr_a = get_lb_redirects();
63

    
64
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Virtual Server"));
65
include("head.inc");
66

    
67
/* active tabs */
68
$tab_array = array();
69
$tab_array[] = array(gettext("Pools"), false, "status_lb_pool.php");
70
$tab_array[] = array(gettext("Virtual Servers"), true, "status_lb_vs.php");
71
display_top_tabs($tab_array);
72

    
73
if(empty($a_vs))
74
	print('<div class="alert alert-danger">No load balancers have been configured!</div>');
75
else {
76
?>
77
	<div class="table-responsive"></div>
78
		<table class="table table-striped table-hover table-condensed">
79
			<tr>
80
				<td><?=gettext("Name"); ?></td>
81
				<td><?=gettext("Address"); ?></td>
82
				<td><?=gettext("Servers"); ?></td>
83
				<td><?=gettext("Status"); ?></td>
84
				<td><?=gettext("Description"); ?></td>
85
			</tr>
86
<?php
87
			$i = 0;
88
			foreach ($a_vs as $vsent): ?>
89
			<tr>
90
				<td>
91
					<?=$vsent['name']?>
92
				</td>
93
				<td>
94
					<?=$vsent['ipaddr']." : ".$vsent['port']?><br />
95
				</td>
96
				<td>
97

    
98
					<?php
99
					foreach ($a_pool as $vipent) {
100
						if ($vipent['name'] == $vsent['poolname']) {
101
							foreach ((array) $vipent['servers'] as $server) { ?>
102
								<?=$server?> <br />
103
<?php
104
							}
105
						}
106
					}
107
?>
108
				</td>
109
				<?php
110
				switch (trim($rdr_a[$vsent['name']]['status'])) {
111
					case 'active':
112
					  $bgcolor = LIGHTGREEN;
113
					  $rdr_a[$vsent['name']]['status'] = "Active";
114
					  break;
115
					case 'down':
116
					  $bgcolor = LIGHTCORAL;
117
					  $rdr_a[$vsent['name']]['status'] = "Down";
118
					  break;
119
					default:
120
					  $bgcolor = LIGHTGRAY;
121
					  $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
122
				  }
123

    
124
				if(!COLOR)
125
					$bgcolor = WHITE;
126
?>
127
				<td bgcolor="<?=$bgcolor?>">
128
					<?=$rdr_a[$vsent['name']]['status']?>
129
				</td>
130
				<td>
131
<?php
132
					if (!empty($rdr_a[$vsent['name']]['total'])) { ?>
133
						Total Sessions: <?=$rdr_a[$vsent['name']]['total']?><br>/><?php
134
					}
135
					if (!empty($rdr_a[$vsent['name']]['last'])) { ?>
136
						Last: <?=$rdr_a[$vsent['name']]['last']?><br>/><?php
137
					}
138
					if (!empty($rdr_a[$vsent['name']]['average'])) { ?>
139
						Average: <?=$rdr_a[$vsent['name']]['average']?><?php
140
					} ?>
141
				</td>
142
				<td>
143
					<?=$vsent['descr']?>
144
				</td>
145
			</tr>
146

    
147
<?php		$i++; endforeach; ?>
148
		 </table>
149
	</div>
150

    
151
<?php }
152

    
153
include("foot.inc"); ?>
(180-180/241)