1 |
a26686cb
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
carp_status.php
|
4 |
|
|
Copyright (C) 2004 Scott Ullrich
|
5 |
|
|
All rights reserved.
|
6 |
|
|
|
7 |
|
|
Redistribution and use in source and binary forms, with or without
|
8 |
|
|
modification, are permitted provided that the following conditions are met:
|
9 |
|
|
|
10 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
11 |
|
|
this list of conditions and the following disclaimer.
|
12 |
|
|
|
13 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
14 |
|
|
notice, this list of conditions and the following disclaimer in the
|
15 |
|
|
documentation and/or other materials provided with the distribution.
|
16 |
|
|
|
17 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
18 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
20 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
30 |
|
|
##|*IDENT=page-status-carp
|
31 |
|
|
##|*NAME=Status: CARP page
|
32 |
|
|
##|*DESCR=Allow access to the 'Status: CARP' page.
|
33 |
|
|
##|*MATCH=carp_status.php*
|
34 |
|
|
##|-PRIV
|
35 |
|
|
|
36 |
|
|
|
37 |
670fafe5
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
38 |
|
|
require_once("xmlparse.inc");
|
39 |
a26686cb
|
Scott Ullrich
|
|
40 |
|
|
function gentitle_pkg($pgname) {
|
41 |
|
|
global $config;
|
42 |
|
|
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
|
43 |
|
|
}
|
44 |
|
|
|
45 |
a1e58090
|
Scott Ullrich
|
unset($interface_arr_cache);
|
46 |
|
|
unset($carp_interface_count_cache);
|
47 |
|
|
unset($carp_query);
|
48 |
07e5afeb
|
Scott Ullrich
|
unset($interface_ip_arr_cache);
|
49 |
a1e58090
|
Scott Ullrich
|
|
50 |
a26686cb
|
Scott Ullrich
|
$status = get_carp_status();
|
51 |
|
|
if($_POST['disablecarp'] <> "") {
|
52 |
|
|
if($status == true) {
|
53 |
|
|
$carp_counter=find_number_of_created_carp_interfaces();
|
54 |
|
|
mwexec("/sbin/sysctl net.inet.carp.allow=0");
|
55 |
|
|
for($x=0; $x<$carp_counter; $x++) {
|
56 |
|
|
mwexec("/sbin/ifconfig carp{$x} down");
|
57 |
|
|
mwexec("/sbin/ifconfig carp{$x} destroy");
|
58 |
|
|
}
|
59 |
|
|
$savemsg = "{$carp_counter} IPs have been disabled.";
|
60 |
|
|
} else {
|
61 |
|
|
$savemsg = "CARP has been enabled.";
|
62 |
|
|
mwexec("/sbin/sysctl net.inet.carp.allow=1");
|
63 |
|
|
interfaces_carp_configure();
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
$status = get_carp_status();
|
68 |
b63695db
|
Scott Ullrich
|
|
69 |
d5fe3bbc
|
Scott Ullrich
|
$pgtitle = array("Status","CARP");
|
70 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
71 |
|
|
|
72 |
a26686cb
|
Scott Ullrich
|
?>
|
73 |
|
|
|
74 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
75 |
e8fc8fa0
|
Erik Kristensen
|
<?php include("fbegin.inc"); ?>
|
76 |
a26686cb
|
Scott Ullrich
|
<form action="carp_status.php" method="post">
|
77 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
78 |
|
|
|
79 |
4208d208
|
Scott Ullrich
|
<div id="mainlevel">
|
80 |
e8fc8fa0
|
Erik Kristensen
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
81 |
|
|
<tr>
|
82 |
|
|
<td class="tabcont">
|
83 |
a26686cb
|
Scott Ullrich
|
<?php
|
84 |
e8fc8fa0
|
Erik Kristensen
|
if(is_array($config['virtualip']['vip'])) {
|
85 |
|
|
foreach($config['virtualip']['vip'] as $carp) {
|
86 |
9175156f
|
Scott Ullrich
|
if ($carp['mode'] == "carp")
|
87 |
|
|
$carpcount++;
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
if($carpcount > 0) {
|
91 |
|
|
if($status == false) {
|
92 |
|
|
$carp_enabled = false;
|
93 |
|
|
echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
|
94 |
|
|
} else {
|
95 |
|
|
$carp_enabled = true;
|
96 |
|
|
echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
|
97 |
e8fc8fa0
|
Erik Kristensen
|
}
|
98 |
|
|
}
|
99 |
a26686cb
|
Scott Ullrich
|
?>
|
100 |
|
|
|
101 |
e8fc8fa0
|
Erik Kristensen
|
<p>
|
102 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
103 |
|
|
<tr>
|
104 |
|
|
<td class="listhdrr"><b><center>Carp Interface</center></b></td>
|
105 |
|
|
<td class="listhdrr"><b><center>Virtual IP</center></b></td>
|
106 |
|
|
<td class="listhdrr"><b><center>Status</center></b></td>
|
107 |
|
|
</tr>
|
108 |
a26686cb
|
Scott Ullrich
|
<?php
|
109 |
172bd075
|
Scott Ullrich
|
if ($carpcount == 0) {
|
110 |
|
|
echo "</td></tr></table></table></div><center><br>Could not locate any defined CARP interfaces.";
|
111 |
|
|
echo "</center>";
|
112 |
|
|
|
113 |
|
|
include("fend.inc");
|
114 |
|
|
echo "</body></html>";
|
115 |
|
|
exit;
|
116 |
|
|
}
|
117 |
|
|
|
118 |
e8fc8fa0
|
Erik Kristensen
|
if(is_array($config['virtualip']['vip'])) {
|
119 |
|
|
$carpint=0;
|
120 |
|
|
foreach($config['virtualip']['vip'] as $carp) {
|
121 |
|
|
if ($carp['mode'] != "carp") continue;
|
122 |
|
|
$ipaddress = $carp['subnet'];
|
123 |
|
|
$password = $carp['password'];
|
124 |
|
|
$netmask = $carp['subnet_bits'];
|
125 |
|
|
$vhid = $carp['vhid'];
|
126 |
|
|
$advskew = $carp['advskew'];
|
127 |
|
|
$carp_int = find_carp_interface($ipaddress);
|
128 |
|
|
$status = get_carp_interface_status($carp_int);
|
129 |
|
|
echo "<tr>";
|
130 |
|
|
$align = "valign='middle'";
|
131 |
|
|
if($carp_enabled == false) {
|
132 |
|
|
$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
|
133 |
|
|
$status = "DISABLED";
|
134 |
|
|
$carp_int = "carp" . $carpint;
|
135 |
|
|
} else {
|
136 |
|
|
if($status == "MASTER") {
|
137 |
|
|
$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
|
138 |
|
|
} else if($status == "BACKUP") {
|
139 |
|
|
$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
|
140 |
|
|
} else if($status == "INIT") {
|
141 |
|
|
$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
echo "<td class=\"listlr\"><center>" . $carp_int . " </td>";
|
145 |
|
|
echo "<td class=\"listlr\"><center>" . $ipaddress . " </td>";
|
146 |
|
|
echo "<td class=\"listlr\"><center>{$icon} " . $status . " </td>";
|
147 |
|
|
echo "</tr>";
|
148 |
|
|
$carpint++;
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
a26686cb
|
Scott Ullrich
|
?>
|
152 |
e8fc8fa0
|
Erik Kristensen
|
<tr>
|
153 |
|
|
<td>
|
154 |
|
|
<center>
|
155 |
a26686cb
|
Scott Ullrich
|
<?php
|
156 |
e8fc8fa0
|
Erik Kristensen
|
echo "<br>pfSync nodes:<br>";
|
157 |
|
|
echo "<pre>";
|
158 |
|
|
system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
|
159 |
|
|
echo "</pre>";
|
160 |
a26686cb
|
Scott Ullrich
|
?>
|
161 |
e8fc8fa0
|
Erik Kristensen
|
</center>
|
162 |
|
|
</td>
|
163 |
|
|
</tr>
|
164 |
|
|
<tr>
|
165 |
|
|
<td colspan="4">
|
166 |
|
|
<p>
|
167 |
|
|
<span class="vexpl">
|
168 |
|
|
<span class="red">
|
169 |
|
|
<strong>
|
170 |
|
|
Note:
|
171 |
|
|
</strong>
|
172 |
|
|
</span>
|
173 |
|
|
<br />
|
174 |
03acfa4a
|
Chris Buechler
|
You can configure CARP settings <a href="pkg_edit.php?xml=carp_settings.xml&id=0">here</a>.
|
175 |
e8fc8fa0
|
Erik Kristensen
|
</span>
|
176 |
|
|
</p>
|
177 |
|
|
</td>
|
178 |
|
|
</tr>
|
179 |
|
|
</table>
|
180 |
|
|
|
181 |
|
|
</td>
|
182 |
|
|
</tr>
|
183 |
|
|
</table>
|
184 |
e2de5461
|
Scott Ullrich
|
</div>
|
185 |
a26686cb
|
Scott Ullrich
|
|
186 |
|
|
<?php include("fend.inc"); ?>
|
187 |
e8fc8fa0
|
Erik Kristensen
|
|
188 |
e2de5461
|
Scott Ullrich
|
|
189 |
a26686cb
|
Scott Ullrich
|
</body>
|
190 |
07bdf973
|
Bill Marquette
|
</html>
|