Project

General

Profile

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