Project

General

Profile

Download (6.5 KB) Statistics
| Branch: | Tag: | Revision:
1 6b09131e Seth Mos
<?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 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/usr/local/sbin/relayctl
33
	pfSense_MODULE:	routing
34
*/
35 6b09131e Seth Mos
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-status-loadbalancer-virtualserver
38
##|*NAME=Status: Load Balancer: Virtual Server page
39
##|*DESCR=Allow access to the 'Status: Load Balancer: Virtual Server' page.
40
##|*MATCH=status_slbd_vs.php*
41
##|-PRIV
42
43 6b09131e Seth Mos
require("guiconfig.inc");
44
45
if (!is_array($config['load_balancer']['lbpool'])) {
46
	$config['load_balancer']['lbpool'] = array();
47
}
48 f852d17b Seth Mos
if (!is_array($config['load_balancer']['virtual_server'])) {
49
	$config['load_balancer']['virtual_server'] = array();
50
}
51 6b09131e Seth Mos
$a_vs = &$config['load_balancer']['virtual_server'];
52
$a_pool = &$config['load_balancer']['lbpool'];
53
54
55
56 e1e543c7 Bill Marquette
// # relayctl show summary
57
// Id   Type      Name                      Avlblty Status
58
// 1    redirect  testvs2                           active
59
// 5    table     test2:80                          active (3 hosts up)
60
// 11   host      192.168.1.2               91.55%  up
61
// 10   host      192.168.1.3               100.00% up
62
// 9    host      192.168.1.4               88.73%  up
63
// 3    table     test:80                           active (1 hosts up)
64
// 7    host      192.168.1.2               66.20%  down
65
// 6    host      192.168.1.3               97.18%  up
66
// 0    redirect  testvs                            active
67
// 3    table     test:80                           active (1 hosts up)
68
// 7    host      192.168.1.2               66.20%  down
69
// 6    host      192.168.1.3               97.18%  up
70
// 4    table     testvs-sitedown:80                active (1 hosts up)
71
// 8    host      192.168.1.4               84.51%  up
72
// # relayctl show redirects
73
// Id   Type      Name                      Avlblty Status
74
// 1    redirect  testvs2                           active
75
// 0    redirect  testvs                            active
76
// # relayctl show redirects
77
// Id   Type      Name                      Avlblty Status
78
// 1    redirect  testvs2                           active
79
//            total: 2 sessions
80
//            last: 2/60s 2/h 2/d sessions
81
//            average: 1/60s 0/h 0/d sessions
82
// 0    redirect  testvs                            active
83
84 933a34dc Ermal Lu?i
$redirects_a = array();
85
exec('/usr/local/sbin/relayctl show redirects 2>&1', $redirects_a);
86
$summary_a = array();
87
exec('/usr/local/sbin/relayctl show summary 2>&1', $summary_a);
88 e1e543c7 Bill Marquette
$rdr_a = parse_redirects($redirects_a);
89
//$server_a = parse_summary($summary_a, parse_redirects($redirects_a));
90
91
function parse_redirects($rdr_a) {
92
  $vs = array();
93
  for ($i = 0; isset($rdr_a[$i]); $i++) {
94
    $line = $rdr_a[$i];
95
    if (preg_match("/^[0-9]+/", $line)) {
96
      $regs = array();
97
      if($x = preg_match("/^[0-9]+\s+redirect\s+([0-9a-zA-Z]+)\s+([a-z]+)/", $line, $regs)) {
98
        $vs[$regs[1]] = array();
99
        $vs[$regs[1]]['status'] = $regs[2];
100
      }
101
    }
102
  }
103
  return $vs;
104
}
105
106
function parse_summary($summary, $rdrs_a) {
107
  $server_a = array();
108
  return $server_a;
109
}
110 6b09131e Seth Mos
111 d88c6a9f Scott Ullrich
$pgtitle = array("Status","Load Balancer","Virtual Server");
112 6b09131e Seth Mos
include("head.inc");
113
114
?>
115
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
116
<?php include("fbegin.inc"); ?>
117
<table width="100%" border="0" cellpadding="0" cellspacing="0">
118 f852d17b Seth Mos
  <tr><td class="tabnavtbl">
119
  <?php
120
        /* active tabs */
121
        $tab_array = array();
122
        $tab_array[] = array("Pools", false, "status_slbd_pool.php");
123
        $tab_array[] = array("Virtual Servers", true, "status_slbd_vs.php");
124
        display_top_tabs($tab_array);
125
  ?>
126
  </td></tr>
127 6b09131e Seth Mos
  <tr>
128
    <td>
129
	<div id="mainarea">
130 3473bb6a Scott Ullrich
              <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
131 6b09131e Seth Mos
                <tr>
132
                  <td width="10%" class="listhdrr">Name</td>
133 3473bb6a Scott Ullrich
				  <td width="10%" class="listhdrr">Port</td>
134 6b09131e Seth Mos
                  <td width="10%" class="listhdrr">Servers</td>
135
                  <td width="30%" class="listhdrr">Status</td>
136
                  <td width="30%" class="listhdr">Description</td>
137
				</tr>
138
			  <?php $i = 0; foreach ($a_vs as $vsent): ?>
139
                <tr>
140
                  <td class="listlr">
141
				<?=$vsent['name'];?>
142
                  </td>
143
                  <td class="listr" align="center" >
144
                                <?=$vsent['port'];?>
145
                                <br />
146
                  </td>
147
                  <td class="listr" align="center" >
148
			<table border="0" cellpadding="0" cellspacing="2">
149
                        <?php
150
			foreach ($a_pool as $vipent) {
151
				if ($vipent['name'] == $vsent['pool']) {
152
					foreach ((array) $vipent['servers'] as $server) {
153 e1e543c7 Bill Marquette
						print "<tr><td> {$server} </td></tr>";
154 6b09131e Seth Mos
					}
155
				}
156
			}
157
			?>
158
			</table>
159
                  </td>
160 e1e543c7 Bill Marquette
                  <?php
161
                  switch ($rdr_a[$vsent['name']]['status']) {
162
                    case 'active':
163
                      $bgcolor = "lightgreen";
164
                      break;
165
                    default:
166
                      $bgcolor = "lightcoral";
167
                  }
168
                  ?>
169
                  <td class="listr" bgcolor="<?=$bgcolor?>">
170
                  <?=$rdr_a[$vsent['name']]['status']?>
171 6b09131e Seth Mos
                  </td>
172
                  <td class="listbg" >
173 d514a16b Scott Ullrich
						<?=$vipent['desc'];?>
174 6b09131e Seth Mos
                  </td>
175
                </tr>
176
		<?php $i++; endforeach; ?>
177
             </table>
178
	   </div>
179
	</table>
180
181
<?php include("fend.inc"); ?>
182
</body>
183
</html>