1 |
a26686cb
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_carp.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10 |
|
|
* you may not use this file except in compliance with the License.
|
11 |
|
|
* You may obtain a copy of the License at
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
16 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18 |
|
|
* See the License for the specific language governing permissions and
|
19 |
|
|
* limitations under the License.
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
21 |
a26686cb
|
Scott Ullrich
|
|
22 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-status-carp
|
24 |
5230f468
|
jim-p
|
##|*NAME=Status: CARP
|
25 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: CARP' page.
|
26 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=status_carp.php*
|
27 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
28 |
|
|
|
29 |
670fafe5
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
30 |
783f1ee2
|
PiBa-NL
|
require_once("globals.inc");
|
31 |
a26686cb
|
Scott Ullrich
|
|
32 |
a1e58090
|
Scott Ullrich
|
unset($interface_arr_cache);
|
33 |
07e5afeb
|
Scott Ullrich
|
unset($interface_ip_arr_cache);
|
34 |
a1e58090
|
Scott Ullrich
|
|
35 |
2a5960b0
|
Luiz Otavio O Souza
|
|
36 |
|
|
function find_ipalias($carpif) {
|
37 |
|
|
global $config;
|
38 |
|
|
|
39 |
|
|
$ips = array();
|
40 |
|
|
foreach ($config['virtualip']['vip'] as $vip) {
|
41 |
d9901ff4
|
Chris Buechler
|
if ($vip['mode'] != "ipalias") {
|
42 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
43 |
d9901ff4
|
Chris Buechler
|
}
|
44 |
|
|
if ($vip['interface'] != $carpif) {
|
45 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
46 |
d9901ff4
|
Chris Buechler
|
}
|
47 |
2a5960b0
|
Luiz Otavio O Souza
|
$ips[] = "{$vip['subnet']}/{$vip['subnet_bits']}";
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
return ($ips);
|
51 |
|
|
}
|
52 |
|
|
|
53 |
a26686cb
|
Scott Ullrich
|
$status = get_carp_status();
|
54 |
9e4bb200
|
Stephen Beaver
|
|
55 |
3575058b
|
Luiz Otavio O Souza
|
if ($status != 0 && $_POST['carp_maintenancemode'] != "") {
|
56 |
783f1ee2
|
PiBa-NL
|
interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"]));
|
57 |
|
|
}
|
58 |
d3a01571
|
Stephen Beaver
|
|
59 |
|
|
if ($_POST['disablecarp'] != "") {
|
60 |
3575058b
|
Luiz Otavio O Souza
|
if ($status != 0) {
|
61 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '0');
|
62 |
b191b7b1
|
Stephen Beaver
|
if (is_array($config['virtualip']['vip'])) {
|
63 |
8e2986f8
|
Ermal
|
$viparr = &$config['virtualip']['vip'];
|
64 |
aae16684
|
Renato Botelho
|
foreach ($viparr as $vip) {
|
65 |
2a5960b0
|
Luiz Otavio O Souza
|
if ($vip['mode'] != "carp" && $vip['mode'] != "ipalias")
|
66 |
|
|
continue;
|
67 |
|
|
if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 4) != "_vip")
|
68 |
|
|
continue;
|
69 |
|
|
|
70 |
|
|
interface_vip_bring_down($vip);
|
71 |
aae16684
|
Renato Botelho
|
}
|
72 |
|
|
}
|
73 |
cccee755
|
Chris Buechler
|
$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot and some configuration changes will re-enable."), $carp_counter);
|
74 |
9c296826
|
Ermal
|
$status = 0;
|
75 |
a26686cb
|
Scott Ullrich
|
} else {
|
76 |
2df8214a
|
Carlos Eduardo Ramos
|
$savemsg = gettext("CARP has been enabled.");
|
77 |
b191b7b1
|
Stephen Beaver
|
if (is_array($config['virtualip']['vip'])) {
|
78 |
aae16684
|
Renato Botelho
|
$viparr = &$config['virtualip']['vip'];
|
79 |
|
|
foreach ($viparr as $vip) {
|
80 |
a133bb38
|
Ermal
|
switch ($vip['mode']) {
|
81 |
b191b7b1
|
Stephen Beaver
|
case "carp":
|
82 |
|
|
interface_carp_configure($vip);
|
83 |
|
|
break;
|
84 |
|
|
case 'ipalias':
|
85 |
d9901ff4
|
Chris Buechler
|
if (substr($vip['interface'], 0, 4) == "_vip") {
|
86 |
b191b7b1
|
Stephen Beaver
|
interface_ipalias_configure($vip);
|
87 |
d9901ff4
|
Chris Buechler
|
}
|
88 |
b191b7b1
|
Stephen Beaver
|
break;
|
89 |
e120d5ce
|
Chris Buechler
|
}
|
90 |
aae16684
|
Renato Botelho
|
}
|
91 |
|
|
}
|
92 |
8ff85c39
|
Ermal
|
interfaces_sync_setup();
|
93 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '1');
|
94 |
9c296826
|
Ermal
|
$status = 1;
|
95 |
a26686cb
|
Scott Ullrich
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
0a4fbd99
|
jim-p
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
99 |
|
|
|
100 |
|
|
if (!empty($_POST['resetdemotion'])) {
|
101 |
52a3580a
|
jim-p
|
set_single_sysctl("net.inet.carp.demotion", 0 - $carp_detected_problems);
|
102 |
0a4fbd99
|
jim-p
|
sleep(1);
|
103 |
|
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
104 |
|
|
}
|
105 |
8a84b3ab
|
jim-p
|
|
106 |
b191b7b1
|
Stephen Beaver
|
$pgtitle = array(gettext("Status"), gettext("CARP"));
|
107 |
b32dd0a6
|
jim-p
|
$shortcut_section = "carp";
|
108 |
d3a01571
|
Stephen Beaver
|
|
109 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
110 |
abe98adb
|
Phil Davis
|
if ($savemsg) {
|
111 |
d3a01571
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
112 |
abe98adb
|
Phil Davis
|
}
|
113 |
8a84b3ab
|
jim-p
|
|
114 |
426522b3
|
Luiz Otavio O Souza
|
if ($status == 0 && $_POST['carp_maintenancemode'] != "") {
|
115 |
|
|
print_info_box('Please enable CARP before setting the maintenance mode.');
|
116 |
|
|
}
|
117 |
|
|
|
118 |
7d5b007c
|
Sjon Hortensius
|
$carpcount = 0;
|
119 |
288a2a0f
|
Phil Davis
|
if (is_array($config['virtualip']['vip'])) {
|
120 |
|
|
foreach ($config['virtualip']['vip'] as $carp) {
|
121 |
7d5b007c
|
Sjon Hortensius
|
if ($carp['mode'] == "carp") {
|
122 |
|
|
$carpcount++;
|
123 |
|
|
break;
|
124 |
|
|
}
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
d3a01571
|
Stephen Beaver
|
|
128 |
|
|
// If $carpcount > 0 display buttons then display table
|
129 |
|
|
// otherwise display error box and quit
|
130 |
|
|
|
131 |
|
|
if ($carpcount == 0) {
|
132 |
|
|
print_info_box(gettext('No CARP interfaces have been defined.') . '<br />' .
|
133 |
0da0d43e
|
Phil Davis
|
'<a href="system_hasync.php" class="alert-link">' .
|
134 |
530c7ccf
|
NOYB
|
gettext("High availability sync settings can be configured here.") .
|
135 |
d3a01571
|
Stephen Beaver
|
'</a>');
|
136 |
abe98adb
|
Phil Davis
|
} else {
|
137 |
d3a01571
|
Stephen Beaver
|
?>
|
138 |
1af5edbf
|
Stephen Beaver
|
<form action="status_carp.php" method="post">
|
139 |
9e4bb200
|
Stephen Beaver
|
<?php
|
140 |
3575058b
|
Luiz Otavio O Souza
|
if ($status != 0) {
|
141 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = true;
|
142 |
abe98adb
|
Phil Davis
|
} else {
|
143 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = false;
|
144 |
abe98adb
|
Phil Davis
|
}
|
145 |
0da0d43e
|
Phil Davis
|
|
146 |
|
|
// Sadly this needs to be here so that it is inside the form
|
147 |
52a3580a
|
jim-p
|
if ($carp_detected_problems != 0) {
|
148 |
61f75117
|
Stephen Beaver
|
print_info_box(
|
149 |
52a3580a
|
jim-p
|
gettext("CARP has detected a problem and this unit has a non-zero demotion status.") .
|
150 |
98128ad6
|
Phil Davis
|
"<br/>" .
|
151 |
52a3580a
|
jim-p
|
gettext("Check the link status on all interfaces configured with CARP VIPs and ") .
|
152 |
|
|
sprintf(gettext('search the %1$sSystem Log%2$s for CARP demotion-related events.'), "<a href=\"/status_logs.php?filtertext=carp%3A+demoted+by\">", "</a>") .
|
153 |
98128ad6
|
Phil Davis
|
"<br/><br/>" .
|
154 |
27d6a45b
|
jim-p
|
'<button type="submit" class="btn btn-warning" name="resetdemotion" id="resetdemotion" value="' .
|
155 |
52a3580a
|
jim-p
|
gettext("Reset CARP Demotion Status") .
|
156 |
27d6a45b
|
jim-p
|
'"><i class="fa fa-undo icon-embed-btn"></i>' .
|
157 |
52a3580a
|
jim-p
|
gettext("Reset CARP Demotion Status") .
|
158 |
27d6a45b
|
jim-p
|
'</button>',
|
159 |
98128ad6
|
Phil Davis
|
'danger'
|
160 |
61f75117
|
Stephen Beaver
|
);
|
161 |
|
|
}
|
162 |
|
|
|
163 |
9e4bb200
|
Stephen Beaver
|
?>
|
164 |
37676f4e
|
jim-p
|
<button type="submit" class="btn btn-warning" name="disablecarp" value="<?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?>" ><i class="fa fa-<?=($carp_enabled) ? 'ban' : 'check' ; ?> icon-embed-btn"></i><?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?></button>
|
165 |
|
|
<button type="submit" class="btn btn-info" name="carp_maintenancemode" id="carp_maintenancemode" value="<?=(isset($config["virtualip_carp_maintenancemode"]) ? gettext("Leave Persistent CARP Maintenance Mode") : gettext("Enter Persistent CARP Maintenance Mode"))?>" ><i class="fa fa-wrench icon-embed-btn"></i><?=(isset($config["virtualip_carp_maintenancemode"]) ? gettext("Leave Persistent CARP Maintenance Mode") : gettext("Enter Persistent CARP Maintenance Mode"))?></button>
|
166 |
0da0d43e
|
Phil Davis
|
|
167 |
d3a01571
|
Stephen Beaver
|
<br /><br />
|
168 |
0da0d43e
|
Phil Davis
|
|
169 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
170 |
6f3a6c31
|
Stephen Beaver
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('CARP Interfaces')?></h2></div>
|
171 |
d3a01571
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
172 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap " data-sortable>
|
173 |
d3a01571
|
Stephen Beaver
|
<thead>
|
174 |
|
|
<tr>
|
175 |
|
|
<th><?=gettext("CARP Interface")?></th>
|
176 |
|
|
<th><?=gettext("Virtual IP")?></th>
|
177 |
|
|
<th><?=gettext("Status")?></th>
|
178 |
|
|
</tr>
|
179 |
|
|
</thead>
|
180 |
|
|
<tbody>
|
181 |
a26686cb
|
Scott Ullrich
|
<?php
|
182 |
288a2a0f
|
Phil Davis
|
foreach ($config['virtualip']['vip'] as $carp) {
|
183 |
|
|
if ($carp['mode'] != "carp") {
|
184 |
7d5b007c
|
Sjon Hortensius
|
continue;
|
185 |
288a2a0f
|
Phil Davis
|
}
|
186 |
0da0d43e
|
Phil Davis
|
|
187 |
1d87a144
|
Luiz Otavio O Souza
|
$icon = '';
|
188 |
7d5b007c
|
Sjon Hortensius
|
$vhid = $carp['vhid'];
|
189 |
f92ea2e2
|
Luiz Otavio O Souza
|
$status = get_carp_interface_status("_vip{$carp['uniqid']}");
|
190 |
2a5960b0
|
Luiz Otavio O Souza
|
$aliases = find_ipalias("_vip{$carp['uniqid']}");
|
191 |
0da0d43e
|
Phil Davis
|
|
192 |
abe98adb
|
Phil Davis
|
if ($carp_enabled == false) {
|
193 |
1b7379f9
|
Jared Dillard
|
$icon = 'times-circle';
|
194 |
7d5b007c
|
Sjon Hortensius
|
$status = "DISABLED";
|
195 |
|
|
} else {
|
196 |
288a2a0f
|
Phil Davis
|
if ($status == "MASTER") {
|
197 |
8f934add
|
jim-p
|
$icon = 'play-circle text-success';
|
198 |
288a2a0f
|
Phil Davis
|
} else if ($status == "BACKUP") {
|
199 |
8f934add
|
jim-p
|
$icon = 'pause-circle text-warning';
|
200 |
288a2a0f
|
Phil Davis
|
} else if ($status == "INIT") {
|
201 |
8f934add
|
jim-p
|
$icon = 'question-circle text-danger';
|
202 |
7d5b007c
|
Sjon Hortensius
|
}
|
203 |
|
|
}
|
204 |
a26686cb
|
Scott Ullrich
|
?>
|
205 |
d3a01571
|
Stephen Beaver
|
<tr>
|
206 |
|
|
<td><?=convert_friendly_interface_to_friendly_descr($carp['interface'])?>@<?=$vhid?></td>
|
207 |
2a5960b0
|
Luiz Otavio O Souza
|
<td>
|
208 |
|
|
<?php
|
209 |
|
|
printf("{$carp['subnet']}/{$carp['subnet_bits']}");
|
210 |
d9901ff4
|
Chris Buechler
|
for ($i = 0; $i < count($aliases); $i++) {
|
211 |
2a5960b0
|
Luiz Otavio O Souza
|
printf("<br>{$aliases[$i]}");
|
212 |
d9901ff4
|
Chris Buechler
|
}
|
213 |
2a5960b0
|
Luiz Otavio O Souza
|
?>
|
214 |
|
|
</td>
|
215 |
1b7379f9
|
Jared Dillard
|
<td><i class="fa fa-<?=$icon?>"></i> <?=$status?></td>
|
216 |
d3a01571
|
Stephen Beaver
|
</tr>
|
217 |
7d5b007c
|
Sjon Hortensius
|
<?php }?>
|
218 |
d3a01571
|
Stephen Beaver
|
</tbody>
|
219 |
|
|
</table>
|
220 |
61f75117
|
Stephen Beaver
|
</div>
|
221 |
d3a01571
|
Stephen Beaver
|
</div>
|
222 |
0f4317d3
|
Colin Fleming
|
</form>
|
223 |
a26686cb
|
Scott Ullrich
|
|
224 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
225 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('pfSync Nodes')?></h2></div>
|
226 |
d3a01571
|
Stephen Beaver
|
<div class="panel-body">
|
227 |
|
|
<ul>
|
228 |
1f919154
|
Scott Ullrich
|
<?php
|
229 |
eef555b9
|
Chris Buechler
|
echo "<br />" . gettext("pfSync nodes") . ":<br />";
|
230 |
|
|
echo "<pre>";
|
231 |
|
|
system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
|
232 |
|
|
echo "</pre>";
|
233 |
1f919154
|
Scott Ullrich
|
?>
|
234 |
eef555b9
|
Chris Buechler
|
|
235 |
d3a01571
|
Stephen Beaver
|
</ul>
|
236 |
|
|
</div>
|
237 |
|
|
</div>
|
238 |
|
|
|
239 |
|
|
<?php
|
240 |
|
|
}
|
241 |
1f919154
|
Scott Ullrich
|
|
242 |
d3a01571
|
Stephen Beaver
|
include("foot.inc");
|