Project

General

Profile

Download (5.07 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>
57
    <td>
58
	<div id="mainarea">
59
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
60
                <tr>
61
                  <td width="10%" class="listhdrr">Name</td>
62
		  <td width="10%" class="listhdrr">Type</td>
63
                  <td width="10%" class="listhdrr">Gateways</td>
64
                  <td width="30%" class="listhdrr">Status</td>
65
                  <td width="30%" class="listhdr">Description</td>
66
				</tr>
67
			  <?php $i = 0; foreach ($a_pool as $vipent): ?>
68
                <tr>
69
                  <td class="listlr">
70
				<?=$vipent['name'];?>
71
                  </td>
72
                  <td class="listr" align="center" >
73
                                <?=$vipent['type'];?>
74
                                <br />
75
                                (<?=$vipent['behaviour'];?>)
76
                  </td>
77
                  <td class="listr" align="center" >
78
			<table border="0" cellpadding="0" cellspacing="2">
79
                        <?php
80
                                foreach ((array) $vipent['servers'] as $server) {
81
                                        $svr = split("\|", $server);
82
					PRINT "<tr><td> {$svr[0]} </td></tr>";
83
                                }
84
                        ?>
85
			</table>
86
                  </td>
87
                  <td class="listr" >
88
			<table border="0" cellpadding="0" cellspacing="2">
89
                        <?php
90
				if ($vipent['type'] == "gateway") {
91
					$poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
92
					if(file_exists("$poolfile")) {
93
						$poolstatus = file_get_contents("$poolfile");
94
					}
95
                                        foreach ((array) $vipent['servers'] as $server) {
96
						$lastchange = "";
97
                                                $svr = split("\|", $server);
98
						$monitorip = $svr[1];
99
						$logstates = return_clog($slbd_logfile, $nentries, array("$monitorip", "marking"), true);
100
						$logstates = $logstates[0];
101

    
102
						if(stristr($logstates, $monitorip)) {
103
							$date = preg_split("/[ ]+/" , $logstates);
104
							$lastchange = "$date[0] $date[1] $year $date[2]";
105
						}
106
						if(stristr($poolstatus, $monitorip)) {
107
							$online = "Online";
108
							$bgcolor = "lightgreen";
109
							$change = $now - strtotime("$lastchange");
110
							if($change < 300) {
111
								$bgcolor = "khaki";
112
							}
113
						} else {
114
							$online = "Offline";
115
							$bgcolor = "lightcoral";
116
						}
117
						PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
118
						if($lastchange <> "") {
119
							PRINT "Last change $lastchange";
120
						} else {
121
							PRINT "No changes found in logfile";
122
						}
123
						PRINT "</td></tr>";
124
                                        }
125
                                } else {
126
					PRINT "<tr><td> {$vipent['monitor']} </td></tr>";
127
                                }
128
                        ?>
129
			</table>
130
                  </td>
131
                  <td class="listbg" >
132
				<font color="#FFFFFF"><?=$vipent['desc'];?></font>
133
                  </td>
134
                </tr>
135
                <?php $i++; endforeach; ?>
136
              </table>
137
	   </div>
138
	</table>
139

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

    
142
<?php include("fend.inc"); ?>
143
</body>
144
</html>
(127-127/167)