Project

General

Profile

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