Project

General

Profile

Download (5.5 KB) Statistics
| Branch: | Tag: | Revision:
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

    
40
require("guiconfig.inc");
41

    
42
if (!is_array($config['load_balancer']['lbpool'])) {
43
	$config['load_balancer']['lbpool'] = array();
44
}
45
$a_pool = &$config['load_balancer']['lbpool'];
46

    
47
$slbd_logfile = "{$g['varlog_path']}/slbd.log";
48

    
49
$nentries = $config['syslog']['nentries'];
50
if (!$nentries)
51
        $nentries = 50;
52

    
53
$now = time();
54
$year = date("Y");
55

    
56
$pgtitle = array("Status","Load Balancer","Pool");
57
include("head.inc");
58

    
59
?>
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61
<?php include("fbegin.inc"); ?>
62
<table width="100%" border="0" cellpadding="0" cellspacing="0">
63
  <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
  <tr>
73
    <td>
74
	<div id="mainarea">
75
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
76
                <tr>
77
                  <td width="10%" class="listhdrr">Name</td>
78
		  <td width="10%" class="listhdrr">Type</td>
79
                  <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
			  <?php $i = 0; foreach ($a_pool as $vipent):
84
				if ($vipent['type'] == "gateway") {
85
			  ?>
86
                <tr>
87
                  <td class="listlr">
88
				<?=$vipent['name'];?>
89
                  </td>
90
                  <td class="listr" align="center" >
91
                                <?=$vipent['type'];?>
92
                                <br />
93
                                (<?=$vipent['behaviour'];?>)
94
                  </td>
95
                  <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
						$logstates = return_clog($slbd_logfile, $nentries, true, array("$monitorip", "marking"), "", true);
118

    
119
						$logstates = $logstates[0];
120

    
121
						if(stristr($logstates, $monitorip)) {
122
							$date = preg_split("/[ ]+/" , $logstates);
123
							$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
						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
                                        }
144
                                } else {
145
					PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
146
                                }
147
                        ?>
148
			</table>
149
                  </td>
150
                  <td class="listbg" >
151
				<font color="#FFFFFF"><?=$vipent['desc'];?></font>
152
                  </td>
153
                </tr>
154
		<?php
155
			}
156
			$i++;
157
		 endforeach;
158
		 ?>
159
              </table>
160
	   </div>
161
	</table>
162

    
163
<?php include("fend.inc"); ?>
164
</body>
165
</html>
(157-157/214)