Project

General

Profile

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