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