Project

General

Profile

Download (5.6 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 1d333258 Scott Ullrich
/*	
32
	pfSense_MODULE:	routing
33
*/
34 6b6a76f9 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+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_slbd_pool.php*
40
##|-PRIV
41
42 6b6a76f9 Scott Ullrich
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
$slbd_logfile = "{$g['varlog_path']}/slbd.log";
50
51
$nentries = $config['syslog']['nentries'];
52
if (!$nentries)
53
        $nentries = 50;
54
55
$now = time();
56
$year = date("Y");
57
58 d88c6a9f Scott Ullrich
$pgtitle = array("Status","Load Balancer","Pool");
59 6b6a76f9 Scott Ullrich
include("head.inc");
60
61
?>
62
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
63 ff9d6728 Scott Ullrich
<script src="/javascript/sorttable.js"></script>
64 6b6a76f9 Scott Ullrich
<?php include("fbegin.inc"); ?>
65
<table width="100%" border="0" cellpadding="0" cellspacing="0">
66 f852d17b Seth Mos
  <tr><td class="tabnavtbl">
67
  <?php
68
        /* active tabs */
69
        $tab_array = array();
70
        $tab_array[] = array("Pools", true, "status_slbd_pool.php");
71
        $tab_array[] = array("Virtual Servers", false, "status_slbd_vs.php");
72
        display_top_tabs($tab_array);
73
  ?>
74
  </td></tr>
75 6b6a76f9 Scott Ullrich
  <tr>
76
    <td>
77
	<div id="mainarea">
78 3473bb6a Scott Ullrich
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont sortable" name="sortabletable" id="sortabletable">
79 6b6a76f9 Scott Ullrich
                <tr>
80
                  <td width="10%" class="listhdrr">Name</td>
81 ff9d6728 Scott Ullrich
				  <td width="10%" class="listhdrr">Type</td>
82 6b6a76f9 Scott Ullrich
                  <td width="10%" class="listhdrr">Gateways</td>
83
                  <td width="30%" class="listhdrr">Status</td>
84
                  <td width="30%" class="listhdr">Description</td>
85
				</tr>
86 c3da9072 Seth Mos
			  <?php $i = 0; foreach ($a_pool as $vipent):
87
				if ($vipent['type'] == "gateway") {
88
			  ?>
89 6b6a76f9 Scott Ullrich
                <tr>
90
                  <td class="listlr">
91
				<?=$vipent['name'];?>
92
                  </td>
93 4190956e Seth Mos
                  <td class="listr" align="center" >
94
                                <?=$vipent['type'];?>
95
                                <br />
96
                                (<?=$vipent['behaviour'];?>)
97
                  </td>
98 6b6a76f9 Scott Ullrich
                  <td class="listr" align="center" >
99
			<table border="0" cellpadding="0" cellspacing="2">
100
                        <?php
101
                                foreach ((array) $vipent['servers'] as $server) {
102
                                        $svr = split("\|", $server);
103
					PRINT "<tr><td> {$svr[0]} </td></tr>";
104
                                }
105
                        ?>
106
			</table>
107
                  </td>
108
                  <td class="listr" >
109
			<table border="0" cellpadding="0" cellspacing="2">
110
                        <?php
111
				if ($vipent['type'] == "gateway") {
112
					$poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
113
					if(file_exists("$poolfile")) {
114
						$poolstatus = file_get_contents("$poolfile");
115
					}
116
                                        foreach ((array) $vipent['servers'] as $server) {
117
						$lastchange = "";
118
                                                $svr = split("\|", $server);
119
						$monitorip = $svr[1];
120 43e7c36c Bill Marquette
						$logstates = return_clog($slbd_logfile, $nentries, true, array("$monitorip", "marking"), "", true);
121
122 d269563b Scott Ullrich
						$logstates = $logstates[0];
123 6b6a76f9 Scott Ullrich
124 d269563b Scott Ullrich
						if(stristr($logstates, $monitorip)) {
125
							$date = preg_split("/[ ]+/" , $logstates);
126 6b6a76f9 Scott Ullrich
							$lastchange = "$date[0] $date[1] $year $date[2]";
127
						}
128
						if(stristr($poolstatus, $monitorip)) {
129
							$online = "Online";
130
							$bgcolor = "lightgreen";
131
							$change = $now - strtotime("$lastchange");
132
							if($change < 300) {
133
								$bgcolor = "khaki";
134
							}
135
						} else {
136
							$online = "Offline";
137
							$bgcolor = "lightcoral";
138
						}
139 d269563b Scott Ullrich
						PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
140
						if($lastchange <> "") {
141
							PRINT "Last change $lastchange";
142
						} else {
143
							PRINT "No changes found in logfile";
144
						}
145
						PRINT "</td></tr>";
146 6b6a76f9 Scott Ullrich
                                        }
147
                                } else {
148
					PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
149
                                }
150
                        ?>
151
			</table>
152
                  </td>
153
                  <td class="listbg" >
154 d514a16b Scott Ullrich
					<?=$vipent['desc'];?>
155 6b6a76f9 Scott Ullrich
                  </td>
156
                </tr>
157 c3da9072 Seth Mos
		<?php
158
			}
159
			$i++;
160
		 endforeach;
161
		 ?>
162 6b6a76f9 Scott Ullrich
              </table>
163
	   </div>
164
	</table>
165 591fe019 Scott Ullrich
166 6b6a76f9 Scott Ullrich
<?php include("fend.inc"); ?>
167
</body>
168
</html>