Project

General

Profile

Download (5.14 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_slbd_vs.php
5
	part of pfSense (http://www.pfsense.com/)
6

    
7
	Copyright (C) 2007 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
if (!is_array($config['load_balancer']['virtual_server'])) {
38
	$config['load_balancer']['virtual_server'] = array();
39
}
40
$a_vs = &$config['load_balancer']['virtual_server'];
41
$a_pool = &$config['load_balancer']['lbpool'];
42

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

    
45
$nentries = $config['syslog']['nentries'];
46
if (!$nentries)
47
        $nentries = 50;
48

    
49
$now = time();
50
$year = date("Y");
51

    
52
$pgtitle = array("Status","Load Balancer","Virtual Server");
53
include("head.inc");
54

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

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

    
153
<?php include("fend.inc"); ?>
154
</body>
155
</html>
(139-139/187)