1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_slbd_pool.php
|
5
|
part of pfSense (http://www.pfsense.com/)
|
6
|
|
7
|
Copyright (C) 2006 Seth Mos <seth.mos@xs4all.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
|
##|+PRIV
|
33
|
##|*IDENT=page-status-loadbalancer-pool
|
34
|
##|*NAME=Status: Load Balancer: Pool page
|
35
|
##|*DESCR=Allow access to the 'Status: Load Balancer: Pool' page.
|
36
|
##|*MATCH=status_slbd_pool.php*
|
37
|
##|-PRIV
|
38
|
|
39
|
require("guiconfig.inc");
|
40
|
|
41
|
if (!is_array($config['load_balancer']['lbpool'])) {
|
42
|
$config['load_balancer']['lbpool'] = array();
|
43
|
}
|
44
|
$a_pool = &$config['load_balancer']['lbpool'];
|
45
|
|
46
|
$slbd_logfile = "{$g['varlog_path']}/slbd.log";
|
47
|
|
48
|
$nentries = $config['syslog']['nentries'];
|
49
|
if (!$nentries)
|
50
|
$nentries = 50;
|
51
|
|
52
|
$now = time();
|
53
|
$year = date("Y");
|
54
|
|
55
|
$pgtitle = array("Status","Load Balancer","Pool");
|
56
|
include("head.inc");
|
57
|
|
58
|
?>
|
59
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
60
|
<?php include("fbegin.inc"); ?>
|
61
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
62
|
<tr><td class="tabnavtbl">
|
63
|
<?php
|
64
|
/* active tabs */
|
65
|
$tab_array = array();
|
66
|
$tab_array[] = array("Pools", true, "status_slbd_pool.php");
|
67
|
$tab_array[] = array("Virtual Servers", false, "status_slbd_vs.php");
|
68
|
display_top_tabs($tab_array);
|
69
|
?>
|
70
|
</td></tr>
|
71
|
<tr>
|
72
|
<td>
|
73
|
<div id="mainarea">
|
74
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
75
|
<tr>
|
76
|
<td width="10%" class="listhdrr">Name</td>
|
77
|
<td width="10%" class="listhdrr">Type</td>
|
78
|
<td width="10%" class="listhdrr">Gateways</td>
|
79
|
<td width="30%" class="listhdrr">Status</td>
|
80
|
<td width="30%" class="listhdr">Description</td>
|
81
|
</tr>
|
82
|
<?php $i = 0; foreach ($a_pool as $vipent):
|
83
|
if ($vipent['type'] == "gateway") {
|
84
|
?>
|
85
|
<tr>
|
86
|
<td class="listlr">
|
87
|
<?=$vipent['name'];?>
|
88
|
</td>
|
89
|
<td class="listr" align="center" >
|
90
|
<?=$vipent['type'];?>
|
91
|
<br />
|
92
|
(<?=$vipent['behaviour'];?>)
|
93
|
</td>
|
94
|
<td class="listr" align="center" >
|
95
|
<table border="0" cellpadding="0" cellspacing="2">
|
96
|
<?php
|
97
|
foreach ((array) $vipent['servers'] as $server) {
|
98
|
$svr = split("\|", $server);
|
99
|
PRINT "<tr><td> {$svr[0]} </td></tr>";
|
100
|
}
|
101
|
?>
|
102
|
</table>
|
103
|
</td>
|
104
|
<td class="listr" >
|
105
|
<table border="0" cellpadding="0" cellspacing="2">
|
106
|
<?php
|
107
|
if ($vipent['type'] == "gateway") {
|
108
|
$poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
|
109
|
if(file_exists("$poolfile")) {
|
110
|
$poolstatus = file_get_contents("$poolfile");
|
111
|
}
|
112
|
foreach ((array) $vipent['servers'] as $server) {
|
113
|
$lastchange = "";
|
114
|
$svr = split("\|", $server);
|
115
|
$monitorip = $svr[1];
|
116
|
$logstates = return_clog($slbd_logfile, $nentries, true, array("$monitorip", "marking"), "", true);
|
117
|
|
118
|
$logstates = $logstates[0];
|
119
|
|
120
|
if(stristr($logstates, $monitorip)) {
|
121
|
$date = preg_split("/[ ]+/" , $logstates);
|
122
|
$lastchange = "$date[0] $date[1] $year $date[2]";
|
123
|
}
|
124
|
if(stristr($poolstatus, $monitorip)) {
|
125
|
$online = "Online";
|
126
|
$bgcolor = "lightgreen";
|
127
|
$change = $now - strtotime("$lastchange");
|
128
|
if($change < 300) {
|
129
|
$bgcolor = "khaki";
|
130
|
}
|
131
|
} else {
|
132
|
$online = "Offline";
|
133
|
$bgcolor = "lightcoral";
|
134
|
}
|
135
|
PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
|
136
|
if($lastchange <> "") {
|
137
|
PRINT "Last change $lastchange";
|
138
|
} else {
|
139
|
PRINT "No changes found in logfile";
|
140
|
}
|
141
|
PRINT "</td></tr>";
|
142
|
}
|
143
|
} else {
|
144
|
PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
|
145
|
}
|
146
|
?>
|
147
|
</table>
|
148
|
</td>
|
149
|
<td class="listbg" >
|
150
|
<?=$vipent['desc'];?>
|
151
|
</td>
|
152
|
</tr>
|
153
|
<?php
|
154
|
}
|
155
|
$i++;
|
156
|
endforeach;
|
157
|
?>
|
158
|
</table>
|
159
|
</div>
|
160
|
</table>
|
161
|
|
162
|
<?php include("fend.inc"); ?>
|
163
|
</body>
|
164
|
</html>
|