Project

General

Profile

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

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

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

    
136
<?php include("fend.inc"); ?>
137
</body>
138
</html>
(126-126/165)