Project

General

Profile

Download (5.18 KB) Statistics
| Branch: | Tag: | Revision:
1 6b09131e Seth Mos
<?php
2
/* $Id$ */
3
/*
4 477dcf13 Chris Buechler
	status_lb_vs.php
5 6b09131e Seth Mos
	part of pfSense (http://www.pfsense.com/)
6
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 6b09131e Seth Mos
	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 477dcf13 Chris Buechler
##|*MATCH=status_lb_vs.php*
41 6b07c15a Matthew Grooms
##|-PRIV
42
43 a776c720 jim-p
require_once("guiconfig.inc");
44
require_once("vslb.inc");
45 6b09131e Seth Mos
46
if (!is_array($config['load_balancer']['lbpool'])) {
47
	$config['load_balancer']['lbpool'] = array();
48
}
49 f852d17b Seth Mos
if (!is_array($config['load_balancer']['virtual_server'])) {
50
	$config['load_balancer']['virtual_server'] = array();
51
}
52 6b09131e Seth Mos
$a_vs = &$config['load_balancer']['virtual_server'];
53
$a_pool = &$config['load_balancer']['lbpool'];
54 a776c720 jim-p
$rdr_a = get_lb_redirects();
55 6b09131e Seth Mos
56 bf3a51cb Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Virtual Server"));
57 6b09131e Seth Mos
include("head.inc");
58
59
?>
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61
<?php include("fbegin.inc"); ?>
62
<table width="100%" border="0" cellpadding="0" cellspacing="0">
63 f852d17b Seth Mos
  <tr><td class="tabnavtbl">
64
  <?php
65
        /* active tabs */
66
        $tab_array = array();
67 bf3a51cb Carlos Eduardo Ramos
        $tab_array[] = array(gettext("Pools"), false, "status_lb_pool.php");
68
        $tab_array[] = array(gettext("Virtual Servers"), true, "status_lb_vs.php");
69 f852d17b Seth Mos
        display_top_tabs($tab_array);
70
  ?>
71
  </td></tr>
72 6b09131e Seth Mos
  <tr>
73
    <td>
74
	<div id="mainarea">
75 3473bb6a Scott Ullrich
              <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
76 6b09131e Seth Mos
                <tr>
77 bf3a51cb Carlos Eduardo Ramos
                  <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
78 e6a8a626 Eirik Oeverby
				  <td width="20%" class="listhdrr"><?=gettext("Address"); ?></td>
79 bf3a51cb Carlos Eduardo Ramos
                  <td width="10%" class="listhdrr"><?=gettext("Servers"); ?></td>
80 ff160984 jim-p
                  <td width="25%" class="listhdrr"><?=gettext("Status"); ?></td>
81
                  <td width="25%" class="listhdr"><?=gettext("Description"); ?></td>
82 6b09131e Seth Mos
				</tr>
83
			  <?php $i = 0; foreach ($a_vs as $vsent): ?>
84
                <tr>
85
                  <td class="listlr">
86
				<?=$vsent['name'];?>
87
                  </td>
88
                  <td class="listr" align="center" >
89 e6a8a626 Eirik Oeverby
                                <?=$vsent['ipaddr']." : ".$vsent['port'];?>
90 6b09131e Seth Mos
                                <br />
91
                  </td>
92
                  <td class="listr" align="center" >
93
			<table border="0" cellpadding="0" cellspacing="2">
94
                        <?php
95
			foreach ($a_pool as $vipent) {
96
				if ($vipent['name'] == $vsent['pool']) {
97
					foreach ((array) $vipent['servers'] as $server) {
98 e1e543c7 Bill Marquette
						print "<tr><td> {$server} </td></tr>";
99 6b09131e Seth Mos
					}
100
				}
101
			}
102
			?>
103
			</table>
104
                  </td>
105 e1e543c7 Bill Marquette
                  <?php
106 e6a8a626 Eirik Oeverby
                  switch (trim($rdr_a[$vsent['name']]['status'])) {
107 e1e543c7 Bill Marquette
                    case 'active':
108
                      $bgcolor = "lightgreen";
109 e6a8a626 Eirik Oeverby
					  $rdr_a[$vsent['name']]['status'] = "Active";
110 e1e543c7 Bill Marquette
                      break;
111 e6a8a626 Eirik Oeverby
                    case 'down':
112 e1e543c7 Bill Marquette
                      $bgcolor = "lightcoral";
113 e6a8a626 Eirik Oeverby
					  $rdr_a[$vsent['name']]['status'] = "Down";
114
					  break;
115
					default:
116
                      $bgcolor = "lightgray";
117
					  $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
118 e1e543c7 Bill Marquette
                  }
119
                  ?>
120 ff160984 jim-p
                  <td class="listr" nowrap>
121
			<table border="0" cellpadding="3" cellspacing="2">
122
				<tr><td bgcolor="<?=$bgcolor?>"><?=$rdr_a[$vsent['name']]['status']?> </td></tr>
123
			</table>
124
			<?php
125
			if (!empty($rdr_a[$vsent['name']]['total']))
126
				echo "Total Sessions: {$rdr_a[$vsent['name']]['total']}\n";
127
			if (!empty($rdr_a[$vsent['name']]['last']))
128
				echo "<br/>Last: {$rdr_a[$vsent['name']]['last']}\n";
129
			if (!empty($rdr_a[$vsent['name']]['average']))
130
				echo "<br/>Average: {$rdr_a[$vsent['name']]['average']}\n";
131
			?>
132 6b09131e Seth Mos
                  </td>
133
                  <td class="listbg" >
134 e988813d jim-p
						<?=$vsent['descr'];?>
135 6b09131e Seth Mos
                  </td>
136
                </tr>
137
		<?php $i++; endforeach; ?>
138
             </table>
139
	   </div>
140
	</table>
141
142
<?php include("fend.inc"); ?>
143
</body>
144
</html>