Project

General

Profile

Download (5.47 KB) Statistics
| Branch: | Tag: | Revision:
1 6b6a76f9 Scott Ullrich
<?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 6b07c15a Matthew Grooms
##|+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 6b6a76f9 Scott Ullrich
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 d88c6a9f Scott Ullrich
$pgtitle = array("Status","Load Balancer","Pool");
56 6b6a76f9 Scott Ullrich
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 f852d17b Seth Mos
  <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 6b6a76f9 Scott Ullrich
  <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 4190956e Seth Mos
		  <td width="10%" class="listhdrr">Type</td>
78 6b6a76f9 Scott Ullrich
                  <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 c3da9072 Seth Mos
			  <?php $i = 0; foreach ($a_pool as $vipent):
83
				if ($vipent['type'] == "gateway") {
84
			  ?>
85 6b6a76f9 Scott Ullrich
                <tr>
86
                  <td class="listlr">
87
				<?=$vipent['name'];?>
88
                  </td>
89 4190956e Seth Mos
                  <td class="listr" align="center" >
90
                                <?=$vipent['type'];?>
91
                                <br />
92
                                (<?=$vipent['behaviour'];?>)
93
                  </td>
94 6b6a76f9 Scott Ullrich
                  <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 43e7c36c Bill Marquette
						$logstates = return_clog($slbd_logfile, $nentries, true, array("$monitorip", "marking"), "", true);
117
118 d269563b Scott Ullrich
						$logstates = $logstates[0];
119 6b6a76f9 Scott Ullrich
120 d269563b Scott Ullrich
						if(stristr($logstates, $monitorip)) {
121
							$date = preg_split("/[ ]+/" , $logstates);
122 6b6a76f9 Scott Ullrich
							$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 d269563b Scott Ullrich
						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 6b6a76f9 Scott Ullrich
                                        }
143
                                } else {
144
					PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
145
                                }
146
                        ?>
147
			</table>
148
                  </td>
149
                  <td class="listbg" >
150 d514a16b Scott Ullrich
					<?=$vipent['desc'];?>
151 6b6a76f9 Scott Ullrich
                  </td>
152
                </tr>
153 c3da9072 Seth Mos
		<?php
154
			}
155
			$i++;
156
		 endforeach;
157
		 ?>
158 6b6a76f9 Scott Ullrich
              </table>
159
	   </div>
160
	</table>
161 591fe019 Scott Ullrich
162 6b6a76f9 Scott Ullrich
<?php include("fend.inc"); ?>
163
</body>
164
</html>