Project

General

Profile

Download (7.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
    carp_status.php
4
    Copyright (C) 2004 Scott Ullrich
5
    Copyright (C) 2013-2014 Electric Sheep Fencing, LP
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-status-carp
32
##|*NAME=Status: CARP page
33
##|*DESCR=Allow access to the 'Status: CARP' page.
34
##|*MATCH=carp_status.php*
35
##|-PRIV
36

    
37
/*
38
	pfSense_MODULE:	carp
39
*/
40

    
41
require_once("guiconfig.inc");
42
require_once("globals.inc");
43

    
44
function gentitle_pkg($pgname) {
45
	global $config;
46
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
47
}
48

    
49
unset($interface_arr_cache);
50
unset($carp_interface_count_cache);
51
unset($interface_ip_arr_cache);
52

    
53
$status = get_carp_status();
54
$status = intval($status);
55
if($_POST['carp_maintenancemode'] <> "") {
56
	interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"]));
57
}
58
if($_POST['disablecarp'] <> "") {
59
	if($status > 0) {
60
		set_single_sysctl('net.inet.carp.allow', '0');
61
		if(is_array($config['virtualip']['vip'])) {
62
			$viparr = &$config['virtualip']['vip'];
63
			foreach ($viparr as $vip) {
64
				switch ($vip['mode']) {
65
				case "carp":
66
					interface_vip_bring_down($vip);
67
					sleep(1);
68
					break;
69
				}
70
			}
71
		}
72
		$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
73
		$status = 0;
74
	} else {
75
		$savemsg = gettext("CARP has been enabled.");
76
		if(is_array($config['virtualip']['vip'])) {
77
			$viparr = &$config['virtualip']['vip'];
78
			foreach ($viparr as $vip) {
79
				switch ($vip['mode']) {
80
				case "carp":
81
					interface_carp_configure($vip);
82
					sleep(1);
83
					break;
84
				case 'ipalias':
85
					if (strpos($vip['interface'], '_vip'))
86
						interface_ipalias_configure($vip);
87
					break;
88
				}
89
			}
90
		}
91
		interfaces_sync_setup();
92
		set_single_sysctl('net.inet.carp.allow', '1');
93
		$status = 1;
94
	}
95
}
96

    
97
$carp_detected_problems = ((get_single_sysctl("net.inet.carp.demotion")) > 0);
98

    
99
$pgtitle = array(gettext("Status"),gettext("CARP"));
100
$shortcut_section = "carp";
101
include("head.inc");
102

    
103
?>
104

    
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106
<?php include("fbegin.inc"); ?>
107
<form action="carp_status.php" method="post">
108
<?php if ($savemsg) print_info_box($savemsg); ?>
109

    
110
<?PHP	if ($carp_detected_problems) print_info_box(gettext("CARP has detected a problem and this unit has been demoted to BACKUP status.") . "<br />" . gettext("Check link status on all interfaces with configured CARP VIPs.")); ?>
111

    
112

    
113
<div id="mainlevel">
114
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="carp status">
115
		<tr>
116
			<td>
117
<?php
118
			$carpcount = 0;
119
			if(is_array($config['virtualip']['vip'])) {
120
				foreach($config['virtualip']['vip'] as $carp) {
121
					if ($carp['mode'] == "carp") {
122
						$carpcount++;
123
						break;
124
					}
125
				}
126
			}
127
			if($carpcount > 0) {
128
				if($status > 0) {
129
					$carp_enabled = true;
130
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Temporarily Disable CARP") . "\" />";
131
				} else {
132
					$carp_enabled = false;
133
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Enable CARP") . "\" />";
134
				}
135
				if(isset($config["virtualip_carp_maintenancemode"])) {
136
					echo "<input type=\"submit\" name=\"carp_maintenancemode\" id=\"carp_maintenancemode\" value=\"" . gettext("Leave Persistent CARP Maintenance Mode") . "\" />";
137
				} else {
138
					echo "<input type=\"submit\" name=\"carp_maintenancemode\" id=\"carp_maintenancemode\" value=\"" . gettext("Enter Persistent CARP Maintenance Mode") . "\" />";
139
				}
140
			}
141
?>
142

    
143
			<br/><br/>
144
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="results">
145
				<tr>
146
					<td class="listhdrr" align="center"><?=gettext("CARP Interface"); ?></td>
147
					<td class="listhdrr" align="center"><?=gettext("Virtual IP"); ?></td>
148
					<td class="listhdrr" align="center"><?=gettext("Status"); ?></td>
149
				</tr>
150
<?php
151
				if ($carpcount == 0) {
152
					echo "</table></td></tr></table></div></form><center><br />" . gettext("Could not locate any defined CARP interfaces.");
153
					echo "</center>";
154

    
155
					include("fend.inc");
156
					echo "</body></html>";
157
					return;
158
				}
159
				if(is_array($config['virtualip']['vip'])) {
160
					foreach($config['virtualip']['vip'] as $carp) {
161
						if ($carp['mode'] != "carp")
162
							continue;
163
						$ipaddress = $carp['subnet'];
164
						$password = $carp['password'];
165
						$netmask = $carp['subnet_bits'];
166
						$vhid = $carp['vhid'];
167
						$advskew = $carp['advskew'];
168
						$advbase = $carp['advbase'];
169
						$status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");
170
						echo "<tr>";
171
						$align = "style=\"vertical-align:middle\"";
172
						if($carp_enabled == false) {
173
							$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_block.gif\" alt=\"disabled\" />";
174
							$status = "DISABLED";
175
						} else {
176
							if($status == "MASTER") {
177
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_pass.gif\" alt=\"master\" />";
178
							} else if($status == "BACKUP") {
179
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_pass_d.gif\" alt=\"backup\" />";
180
							} else if($status == "INIT") {
181
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_log.gif\" alt=\"init\" />";
182
							}
183
						}
184
						echo "<td class=\"listlr\" align=\"center\">" . convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid} &nbsp;</td>";
185
						echo "<td class=\"listlr\" align=\"center\">" . $ipaddress . "&nbsp;</td>";
186
						echo "<td class=\"listlr\" align=\"center\">{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
187
						echo "</tr>";
188
					}
189
				}
190
?>
191
			</table>
192
			</td>
193
		</tr>
194
	</table>
195
</div>
196
</form>
197

    
198
<p class="vexpl">
199
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
200
<br />
201
<?=gettext("You can configure high availability sync settings"); ?> <a href="system_hasync.php"><?=gettext("here"); ?></a>.
202
</p>
203

    
204
<?php
205
	echo "<br />" . gettext("pfSync nodes") . ":<br />";
206
	echo "<pre>";
207
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
208
	echo "</pre>";
209
?>
210

    
211
<?php include("fend.inc"); ?>
212

    
213
</body>
214
</html>
(3-3/256)