Project

General

Profile

Download (5.54 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 670fafe5 Scott Ullrich
require_once("guiconfig.inc");
30
require_once("xmlparse.inc");
31 a26686cb Scott Ullrich
32
function gentitle_pkg($pgname) {
33
	global $config;
34
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
35
}
36
37 0343ba63 Scott Ullrich
unset($interface_arr_cache);
38
unset($carp_interface_count_cache);
39
unset($carp_query);
40 1946c7dc Scott Ullrich
unset($interface_ip_arr_cache);
41 0343ba63 Scott Ullrich
42 a26686cb Scott Ullrich
$status = get_carp_status();
43
if($_POST['disablecarp'] <> "") {
44
	if($status == true) {
45
		$carp_counter=find_number_of_created_carp_interfaces();
46
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
47
		for($x=0; $x<$carp_counter; $x++) {
48
			mwexec("/sbin/ifconfig carp{$x} down");
49 612b579a Scott Ullrich
			mwexec("/sbin/ifconfig carp{$x} delete");
50 a26686cb Scott Ullrich
		}
51
		$savemsg = "{$carp_counter} IPs have been disabled.";
52
	} else {
53
		$savemsg = "CARP has been enabled.";
54
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
55
		interfaces_carp_configure();
56 66766f85 Scott Ullrich
		interfaces_carp_bring_up_final();
57 a26686cb Scott Ullrich
	}
58
}
59
60
$status = get_carp_status();
61 b63695db Scott Ullrich
62
$pgtitle = "CARP: Status";
63
include("head.inc");
64
65 a26686cb Scott Ullrich
?>
66
67
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
68 e8fc8fa0 Erik Kristensen
<?php include("fbegin.inc"); ?>
69 d6244d2f Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
70 a26686cb Scott Ullrich
<form action="carp_status.php" method="post">
71
<?php if ($savemsg) print_info_box($savemsg); ?>
72
73 4208d208 Scott Ullrich
<div id="mainlevel">
74 e8fc8fa0 Erik Kristensen
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
75
		<tr>
76
			<td class="tabcont">
77 a26686cb Scott Ullrich
<?php
78 e8fc8fa0 Erik Kristensen
			if($status == false) {
79
				$carp_enabled = false;
80
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
81
			} else {
82
				$carp_enabled = true;
83
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
84
			}
85 018a4be7 Scott Ullrich
86 e8fc8fa0 Erik Kristensen
			if(is_array($config['virtualip']['vip'])) {
87
				foreach($config['virtualip']['vip'] as $carp) {
88
					if ($carp['mode'] == "carp") $carpcount++;
89
				}
90
				if ($carpcount == 0) {
91
					echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
92
					echo "</center>";
93
94
					include("fend.inc");
95
					echo "</body></html>";
96
					exit;
97
				}
98
			}
99 a26686cb Scott Ullrich
?>
100
101 e8fc8fa0 Erik Kristensen
			<p>
102
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
103
				<tr>
104
					<td class="listhdrr"><b><center>Carp Interface</center></b></td>
105
					<td class="listhdrr"><b><center>Virtual IP</center></b></td>
106
					<td class="listhdrr"><b><center>Status</center></b></td>
107
				</tr>
108 a26686cb Scott Ullrich
<?php
109 e8fc8fa0 Erik Kristensen
				if(is_array($config['virtualip']['vip'])) {
110
					$carpint=0;
111
					foreach($config['virtualip']['vip'] as $carp) {
112
						if ($carp['mode'] != "carp") continue;
113
						$ipaddress = $carp['subnet'];
114
						$password = $carp['password'];
115
						$netmask = $carp['subnet_bits'];
116
						$vhid = $carp['vhid'];
117
						$advskew = $carp['advskew'];
118
						$carp_int = find_carp_interface($ipaddress);
119
						$status = get_carp_interface_status($carp_int);
120
						echo "<tr>";
121
						$align = "valign='middle'";
122
						if($carp_enabled == false) {
123
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
124
							$status = "DISABLED";
125
							$carp_int = "carp" . $carpint;
126
						} else {
127
							if($status == "MASTER") {
128
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
129
							} else if($status == "BACKUP") {
130
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
131
							} else if($status == "INIT") {
132
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
133
							}
134
						}
135
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
136
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
137
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
138
						echo "</tr>";
139
						$carpint++;
140
					}
141
				}
142 a26686cb Scott Ullrich
?>
143 e8fc8fa0 Erik Kristensen
				<tr>
144
					<td>
145
						<center>
146 a26686cb Scott Ullrich
<?php
147 e8fc8fa0 Erik Kristensen
						echo "<br>pfSync nodes:<br>";
148
						echo "<pre>";
149
						system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
150
						echo "</pre>";
151 a26686cb Scott Ullrich
?>
152 e8fc8fa0 Erik Kristensen
						</center>
153
					</td>
154
				</tr>
155
				<tr>
156
					<td colspan="4">
157
						<p>
158
						<span class="vexpl">
159
						<span class="red">
160
						<strong>
161
						Note:
162
        				</strong>
163
						</span>
164
						<br />
165 79ec2fe1 Chris Buechler
						You can configure CARP settings <a href="pkg_edit.php?xml=carp_settings.xml&id=0">here</a>.
166 e8fc8fa0 Erik Kristensen
						</span>
167
						</p>
168
					</td>
169
				</tr>
170
			</table>
171
172
			</td>
173
		</tr>
174
	</table>
175 e2de5461 Scott Ullrich
</div>
176 a26686cb Scott Ullrich
177
<?php include("fend.inc"); ?>
178 e8fc8fa0 Erik Kristensen
179 e2de5461 Scott Ullrich
180 a26686cb Scott Ullrich
</body>
181 07bdf973 Bill Marquette
</html>