Project

General

Profile

Download (5.41 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
require("guiconfig.inc");
33

    
34
if (!is_array($config['load_balancer']['lbpool'])) {
35
	$config['load_balancer']['lbpool'] = array();
36
}
37
$a_pool = &$config['load_balancer']['lbpool'];
38

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

    
41
$nentries = $config['syslog']['nentries'];
42
if (!$nentries)
43
        $nentries = 50;
44

    
45
$now = time();
46
$year = date("Y");
47

    
48
$pgtitle = "Status: Load Balancer: Pool";
49
include("head.inc");
50

    
51
?>
52
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
53
<?php include("fbegin.inc"); ?>
54
<p class="pgtitle"><?=$pgtitle?></p>
55
<table width="100%" border="0" cellpadding="0" cellspacing="0">
56
  <tr><td class="tabnavtbl">
57
  <?php
58
        /* active tabs */
59
        $tab_array = array();
60
        $tab_array[] = array("Pools", true, "status_slbd_pool.php");
61
        $tab_array[] = array("Virtual Servers", false, "status_slbd_vs.php");
62
        display_top_tabs($tab_array);
63
  ?>
64
  </td></tr>
65
  <tr>
66
    <td>
67
	<div id="mainarea">
68
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
69
                <tr>
70
                  <td width="10%" class="listhdrr">Name</td>
71
		  <td width="10%" class="listhdrr">Type</td>
72
                  <td width="10%" class="listhdrr">Gateways</td>
73
                  <td width="30%" class="listhdrr">Status</td>
74
                  <td width="30%" class="listhdr">Description</td>
75
				</tr>
76
			  <?php $i = 0; foreach ($a_pool as $vipent):
77
				if ($vipent['type'] == "gateway") {
78
			  ?>
79
                <tr>
80
                  <td class="listlr">
81
				<?=$vipent['name'];?>
82
                  </td>
83
                  <td class="listr" align="center" >
84
                                <?=$vipent['type'];?>
85
                                <br />
86
                                (<?=$vipent['behaviour'];?>)
87
                  </td>
88
                  <td class="listr" align="center" >
89
			<table border="0" cellpadding="0" cellspacing="2">
90
                        <?php
91
                                foreach ((array) $vipent['servers'] as $server) {
92
                                        $svr = split("\|", $server);
93
					PRINT "<tr><td> {$svr[0]} </td></tr>";
94
                                }
95
                        ?>
96
			</table>
97
                  </td>
98
                  <td class="listr" >
99
			<table border="0" cellpadding="0" cellspacing="2">
100
                        <?php
101
				if ($vipent['type'] == "gateway") {
102
					$poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
103
					if(file_exists("$poolfile")) {
104
						$poolstatus = file_get_contents("$poolfile");
105
					}
106
                                        foreach ((array) $vipent['servers'] as $server) {
107
						$lastchange = "";
108
                                                $svr = split("\|", $server);
109
						$monitorip = $svr[1];
110
						$logstates = return_clog($slbd_logfile, $nentries, array("$monitorip", "marking"), true);
111
						$logstates = $logstates[0];
112

    
113
						if(stristr($logstates, $monitorip)) {
114
							$date = preg_split("/[ ]+/" , $logstates);
115
							$lastchange = "$date[0] $date[1] $year $date[2]";
116
						}
117
						if(stristr($poolstatus, $monitorip)) {
118
							$online = "Online";
119
							$bgcolor = "lightgreen";
120
							$change = $now - strtotime("$lastchange");
121
							if($change < 300) {
122
								$bgcolor = "khaki";
123
							}
124
						} else {
125
							$online = "Offline";
126
							$bgcolor = "lightcoral";
127
						}
128
						PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
129
						if($lastchange <> "") {
130
							PRINT "Last change $lastchange";
131
						} else {
132
							PRINT "No changes found in logfile";
133
						}
134
						PRINT "</td></tr>";
135
                                        }
136
                                } else {
137
					PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
138
                                }
139
                        ?>
140
			</table>
141
                  </td>
142
                  <td class="listbg" >
143
				<font color="#FFFFFF"><?=$vipent['desc'];?></font>
144
                  </td>
145
                </tr>
146
		<?php
147
			}
148
			$i++;
149
		 endforeach;
150
		 ?>
151
              </table>
152
	   </div>
153
	</table>
154

    
155
<meta http-equiv="refresh" content="120;url=<?php print $_SERVER['SCRIPT_NAME']; ?>">
156

    
157
<?php include("fend.inc"); ?>
158
</body>
159
</html>
(137-137/181)