Project

General

Profile

Download (5.36 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_lb_pool.php
5
	part of pfSense (http://www.pfsense.com/)
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_MODULE:	routing
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-status-loadbalancer-pool
37
##|*NAME=Status: Load Balancer: Pool page
38
##|*DESCR=Allow access to the 'Status: Load Balancer: Pool' page.
39
##|*MATCH=status_lb_pool.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43

    
44
if (!is_array($config['load_balancer']['lbpool'])) {
45
	$config['load_balancer']['lbpool'] = array();
46
}
47
$a_pool = &$config['load_balancer']['lbpool'];
48

    
49
$lb_logfile = "{$g['varlog_path']}/relayd.log";
50

    
51
$nentries = $config['syslog']['nentries'];
52
if (!$nentries)
53
	$nentries = 50;
54

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

    
58
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Pool"));
59
include("head.inc");
60

    
61
$relayctl=split("\n", shell_exec("/usr/local/sbin/relayctl show summary"));
62
$relay_hosts=Array();
63
foreach( (array) $relayctl as $line) {
64
	$t=split("\t", $line);
65
	switch (trim($t[1])) {
66
		case "table":
67
			$curpool=trim($t[2]);
68
		break;
69
		case "host":
70
			$curhost=trim($t[2]);
71
			$relay_hosts[$curpool][$curhost]['state']=trim($t[4]);
72
		break;
73
	}
74
}
75

    
76
?>
77
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
78
<script src="/javascript/sorttable.js"></script>
79
<?php include("fbegin.inc"); ?>
80
<form action="status_lb_pool.php" method="POST">
81
<table width="100%" border="0" cellpadding="0" cellspacing="0">
82
	<tr><td class="tabnavtbl">
83
	<?php
84
	/* active tabs */
85
	$tab_array = array();
86
	$tab_array[] = array(gettext("Pools"), true, "status_lb_pool.php");
87
	$tab_array[] = array(gettext("Virtual Servers"), false, "status_lb_vs.php");
88
	display_top_tabs($tab_array);
89
	?>
90
	</td></tr>
91
	<tr>
92
	<td>
93
	<div id="mainarea">
94
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont sortable" name="sortabletable" id="sortabletable">
95
		<tr>
96
		<td width="10%" class="listhdrr"><?=gettext("Name");?></td>
97
		<td width="10%" class="listhdrr"><?=gettext("Mode");?></td>
98
		<td width="10%" class="listhdrr"><?=gettext("Servers");?></td>
99
		<td width="10%" class="listhdrr"><?=gettext("Monitor");?></td>
100
		<td width="30%" class="listhdr"><?=gettext("Description");?></td>
101
		</tr>
102
		<?php $i = 0; foreach ($a_pool as $pool): ?>
103
		<tr>
104
		<td class="listlr">
105
			<?=$pool['name'];?>
106
		</td>
107
		<td class="listr" align="center" >
108
		<?php
109
		switch($pool['mode']) {
110
			case "loadbalance":
111
				echo "Load balancing";
112
				break;
113
			case "failover":
114
				echo "Manual failover";
115
				break;
116
			default:
117
				echo "(default)";
118
		}
119
		?>
120
		</td>
121
		<td class="listr" align="center" >
122
		<table border="0" cellpadding="0" cellspacing="2">
123
		<?php
124
		foreach ((array) $pool['servers'] as $server) {
125
			$svr = split("\|", $server);
126
			if($svr[0]!="") {
127
				switch ($relay_hosts[$pool['name'].":".$pool['port']][$svr[0]]['state']) {
128
					case 'up':
129
						$bgcolor = "lightgreen";
130
						break;
131
					default:
132
						$bgcolor = "lightcoral";
133
				}
134
				echo "<tr>";
135
				switch ($pool['mode']) {
136
					case 'loadbalance':
137
						if($svr[0]!="")
138
							echo "<td><input type='checkbox' name='{$pool['name']}_{$svr[0]}' checked></td>";
139
						break;
140
					case 'failover':
141
						if($svr[0]!="")
142
							echo "<td><input type='radio' name='{$pool['name']}' checked></td>";
143
						break;
144
				}
145
				echo "<td bgcolor={$bgcolor}> {$svr[0]}:{$pool['port']} </td></tr>";
146
			}
147
		}
148
		foreach ((array) $pool['serversdisabled'] as $server) {
149
			$svr = split("\|", $server);
150
			echo "<tr>";
151
			switch ($pool['mode']) {
152
				case 'loadbalance':
153
					if($svr[0]!="")
154
						echo "<td><input type='checkbox' name='{$pool['name']}_{$svr[0]}'></td>";
155
					break;
156
				case 'failover':
157
					if($svr[0]!="")
158
						echo "<td><input type='radio' name='{$pool['name']}'></td>";
159
					break;
160
			}
161
			echo "<td> {$svr[0]}:{$pool['port']} </td></tr>";
162
		}
163
		?>
164
		</table>
165
		</td>
166
		<td class="listr" >
167
			<?php echo $pool['monitor']; ?>
168
		</td>
169
		<td class="listbg" >
170
			<?=$pool['desc'];?>
171
		</td>
172
		</tr>
173
		<?php
174
			$i++;
175
		 endforeach;
176
		 ?>
177
		<tr>
178
			<td colspan="5">
179
			<input name="Submit" type="submit" class="formbtn" value="<?= gettext("Save"); ?>">
180
			<input name="Reset"  type="reset"  class="formbtn" value="<?= gettext("Reset"); ?>">
181
			</td>
182
		</tr>
183
		</table>
184
	</div>
185
	</table>
186
</form>
187
<?php include("fend.inc"); ?>
188
</body>
189
</html>
(162-162/222)