Project

General

Profile

Download (6.7 KB) Statistics
| Branch: | Tag: | Revision:
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 13d193c2 Scott Ullrich
/*
37
	pfSense_BUILDER_BINARIES:	/sbin/sysctl	
38
	pfSense_MODULE:	carp
39
*/
40 6b07c15a Matthew Grooms
41 670fafe5 Scott Ullrich
require_once("guiconfig.inc");
42 a26686cb Scott Ullrich
43
function gentitle_pkg($pgname) {
44
	global $config;
45
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
46
}
47
48 a1e58090 Scott Ullrich
unset($interface_arr_cache);
49
unset($carp_interface_count_cache);
50 07e5afeb Scott Ullrich
unset($interface_ip_arr_cache);
51 a1e58090 Scott Ullrich
52 a26686cb Scott Ullrich
$status = get_carp_status();
53
if($_POST['disablecarp'] <> "") {
54
	if($status == true) {
55
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
56 8e2986f8 Ermal
		if(is_array($config['virtualip']['vip'])) {
57
			$viparr = &$config['virtualip']['vip'];
58
                	foreach ($viparr as $vip) {
59 a133bb38 Ermal
                               	switch ($vip['mode']) {
60
                                       	case "carp":
61
                                       		interface_vip_bring_down($vip);
62
                                       		sleep(1);
63
                                       	break;
64
                                       	case "carpdev-dhcp":
65
                                       		interface_vip_bring_down($vip);
66
                                       		sleep(1);
67
                                       	break;
68
                               	}
69 8e2986f8 Ermal
                	}
70
        	}
71 24143605 Scott Ullrich
		$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
72 a26686cb Scott Ullrich
	} else {
73 2df8214a Carlos Eduardo Ramos
		$savemsg = gettext("CARP has been enabled.");
74 a26686cb Scott Ullrich
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
75 0a595d84 Ermal Lu?i
		interfaces_carp_setup();
76 8e2986f8 Ermal
		if(is_array($config['virtualip']['vip'])) {
77
                        $viparr = &$config['virtualip']['vip'];
78
                        foreach ($viparr as $vip) {
79 a133bb38 Ermal
				switch ($vip['mode']) {
80
					case "carp":
81
						interface_carp_configure($vip);
82
						sleep(1);
83
					break;
84
					case "carpdev-dhcp":
85
						interface_carpdev_configure($vip);
86
						sleep(1);
87
					break;
88 8e2986f8 Ermal
                                }
89
                        }
90
                }
91 a26686cb Scott Ullrich
	}
92
}
93
94
$status = get_carp_status();
95 b63695db Scott Ullrich
96 2df8214a Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("CARP"));
97 b63695db Scott Ullrich
include("head.inc");
98
99 a26686cb Scott Ullrich
?>
100
101
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
102 e8fc8fa0 Erik Kristensen
<?php include("fbegin.inc"); ?>
103 a26686cb Scott Ullrich
<form action="carp_status.php" method="post">
104
<?php if ($savemsg) print_info_box($savemsg); ?>
105
106 4208d208 Scott Ullrich
<div id="mainlevel">
107 e8fc8fa0 Erik Kristensen
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
108
		<tr>
109 1f919154 Scott Ullrich
			<td>
110 a26686cb Scott Ullrich
<?php
111 2bfade90 Ermal
			$carpcount = 0;
112 e8fc8fa0 Erik Kristensen
			if(is_array($config['virtualip']['vip'])) {
113
				foreach($config['virtualip']['vip'] as $carp) {
114 4ed5ad5a Ermal
					if ($carp['mode'] == "carp") {
115 9175156f Scott Ullrich
						$carpcount++;
116 4ed5ad5a Ermal
						break;
117
					}
118 9175156f Scott Ullrich
				}
119
			}
120
			if($carpcount > 0) {
121
				if($status == false) {
122
					$carp_enabled = false;
123 2df8214a Carlos Eduardo Ramos
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Enable Carp") . "\">";
124 9175156f Scott Ullrich
				} else {
125
					$carp_enabled = true;
126 2df8214a Carlos Eduardo Ramos
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Disable Carp") . "\">";
127 e8fc8fa0 Erik Kristensen
				}
128
			}
129 a26686cb Scott Ullrich
?>
130
131 e8fc8fa0 Erik Kristensen
			<p>
132 3473bb6a Scott Ullrich
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
133 e8fc8fa0 Erik Kristensen
				<tr>
134 2df8214a Carlos Eduardo Ramos
					<td class="listhdrr"><b><center><?=gettext("CARP Interface"); ?></center></b></td>
135
					<td class="listhdrr"><b><center><?=gettext("Virtual IP"); ?></center></b></td>
136
					<td class="listhdrr"><b><center><?=gettext("Status"); ?></center></b></td>
137 e8fc8fa0 Erik Kristensen
				</tr>
138 a26686cb Scott Ullrich
<?php
139 172bd075 Scott Ullrich
				if ($carpcount == 0) {
140 381af659 Renato Botelho
					echo "</td></tr></table></table></div><center><br>" . gettext("Could not locate any defined CARP interfaces.");
141 172bd075 Scott Ullrich
					echo "</center>";
142
143
					include("fend.inc");
144
					echo "</body></html>";
145
					exit;
146
				}
147
148 e8fc8fa0 Erik Kristensen
				if(is_array($config['virtualip']['vip'])) {
149
					foreach($config['virtualip']['vip'] as $carp) {
150 4ed5ad5a Ermal
						if ($carp['mode'] != "carp")
151
							continue;
152 e8fc8fa0 Erik Kristensen
						$ipaddress = $carp['subnet'];
153
						$password = $carp['password'];
154
						$netmask = $carp['subnet_bits'];
155
						$vhid = $carp['vhid'];
156
						$advskew = $carp['advskew'];
157 6f247d1f Ermal
						$advbase = $carp['advbase'];
158 4ed5ad5a Ermal
						$carp_int = "vip{$vhid}";
159 e8fc8fa0 Erik Kristensen
						$status = get_carp_interface_status($carp_int);
160
						echo "<tr>";
161
						$align = "valign='middle'";
162
						if($carp_enabled == false) {
163
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
164
							$status = "DISABLED";
165
						} else {
166
							if($status == "MASTER") {
167
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
168
							} else if($status == "BACKUP") {
169
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
170
							} else if($status == "INIT") {
171
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
172
							}
173
						}
174
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
175
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
176
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
177
						echo "</tr>";
178
					}
179
				}
180 a26686cb Scott Ullrich
?>
181 e8fc8fa0 Erik Kristensen
			</table>
182
			</td>
183
		</tr>
184
	</table>
185 e2de5461 Scott Ullrich
</div>
186 a26686cb Scott Ullrich
187 1f919154 Scott Ullrich
<p/>
188
189
<span class="vexpl">
190 2df8214a Carlos Eduardo Ramos
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
191 1f919154 Scott Ullrich
<br />
192 2df8214a Carlos Eduardo Ramos
<?=gettext("You can configure CARP settings"); ?> <a href="pkg_edit.php?xml=carp_settings.xml&id=0"><?=gettext("here"); ?></a>.
193 1f919154 Scott Ullrich
</span>
194 e8fc8fa0 Erik Kristensen
195 1f919154 Scott Ullrich
<p/>
196
197
<?php
198 2df8214a Carlos Eduardo Ramos
	echo "<br>" . gettext("pfSync nodes") . ":<br>";
199 1f919154 Scott Ullrich
	echo "<pre>";
200
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
201
	echo "</pre>";
202
?>
203
204
<?php include("fend.inc"); ?>
205 e2de5461 Scott Ullrich
206 a26686cb Scott Ullrich
</body>
207 07bdf973 Bill Marquette
</html>