Project

General

Profile

Download (5.18 KB) Statistics
| Branch: | Tag: | Revision:
1 a26686cb Scott Ullrich
#!/usr/local/bin/php
2
<?php
3
/*
4
    carp_status.php
5
    Copyright (C) 2004 Scott Ullrich
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 670fafe5 Scott Ullrich
require_once("guiconfig.inc");
31
require_once("xmlparse.inc");
32 a26686cb Scott Ullrich
33
function gentitle_pkg($pgname) {
34
	global $config;
35
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
36
}
37
38
$status = get_carp_status();
39
if($_POST['disablecarp'] <> "") {
40
	if($status == true) {
41
		$carp_counter=find_number_of_created_carp_interfaces();
42
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
43
		for($x=0; $x<$carp_counter; $x++) {
44
			mwexec("/sbin/ifconfig carp{$x} down");
45
			mwexec("/sbin/ifconfig carp{$x} destroy");
46
		}
47
		$savemsg = "{$carp_counter} IPs have been disabled.";
48
	} else {
49
		$savemsg = "CARP has been enabled.";
50
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
51
		interfaces_carp_configure();
52
		interfaces_carp_bringup();
53
	}
54
}
55
56
$status = get_carp_status();
57 b63695db Scott Ullrich
58
$pgtitle = "CARP: Status";
59
include("head.inc");
60
61 a26686cb Scott Ullrich
?>
62
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php
65
include("fbegin.inc");
66
?>
67 d6244d2f Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
68 a26686cb Scott Ullrich
<form action="carp_status.php" method="post">
69
<?php if ($savemsg) print_info_box($savemsg); ?>
70
71 4208d208 Scott Ullrich
<div id="mainlevel">
72 a26686cb Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
73 e2de5461 Scott Ullrich
<tr><td class="tabcont">
74
75 a26686cb Scott Ullrich
<?php
76
	if($status == false) {
77
		$carp_enabled = false;
78
		echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
79
	} else {
80
		$carp_enabled = true;
81
		echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
82
	}
83
84 1425e067 Bill Marquette
if(is_array($config['virtualip']['vip'])) {
85
	foreach($config['virtualip']['vip'] as $carp) {
86
		if ($carp['mode'] == "carp") $carpcount++;
87
	}
88
	if ($carpcount == 0) {
89 e2de5461 Scott Ullrich
	echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
90 018a4be7 Scott Ullrich
	echo "</center>";
91
92 2f76f7aa Scott Ullrich
	include("fend.inc");
93 54dce66f Scott Ullrich
	echo "</body></html>";
94 a26686cb Scott Ullrich
	exit;
95 1425e067 Bill Marquette
	}
96 a26686cb Scott Ullrich
}
97
?>
98
99
<p>
100
101 e2de5461 Scott Ullrich
<table width="100%" border="0" cellpadding="6" cellspacing="0">
102 a26686cb Scott Ullrich
</tr>
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
<?php
109
110 1425e067 Bill Marquette
if(is_array($config['virtualip']['vip'])) {
111 a26686cb Scott Ullrich
	$carpint=0;
112 1425e067 Bill Marquette
	foreach($config['virtualip']['vip'] as $carp) {
113
		if ($carp['mode'] != "carp") continue;
114
		$ipaddress = $carp['subnet'];
115 a26686cb Scott Ullrich
		$password = $carp['password'];
116 1425e067 Bill Marquette
		$netmask = $carp['subnet_bits'];
117 a26686cb Scott Ullrich
		$vhid = $carp['vhid'];
118
		$advskew = $carp['advskew'];
119
		$carp_int = find_carp_interface($ipaddress);
120
		$status = get_carp_interface_status($carp_int);
121
		echo "<tr>";
122
		$align = "valign='middle'";
123
		if($carp_enabled == false) {
124 677c0869 Erik Kristensen
			$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
125 a26686cb Scott Ullrich
			$status = "DISABLED";
126
			$carp_int = "carp" . $carpint;
127
		} else {
128
			if($status == "MASTER") {
129 677c0869 Erik Kristensen
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
130 a26686cb Scott Ullrich
			} else if($status == "BACKUP") {
131 677c0869 Erik Kristensen
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
132 a26686cb Scott Ullrich
			} else if($status == "INIT") {
133 677c0869 Erik Kristensen
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
134 a26686cb Scott Ullrich
			}
135
		}
136
		echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
137
		echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
138
		echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
139
		echo "</tr>";
140
		$carpint++;
141
	}
142 1425e067 Bill Marquette
}
143 a26686cb Scott Ullrich
?>
144
<tr><td>
145
<center>
146
<?php
147
  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
?>
152
</center>
153 c55a8ab9 Holger Bauer
154 a26686cb Scott Ullrich
</td></tr>
155 c55a8ab9 Holger Bauer
<td colspan="4">
156
	<p><span class="vexpl"><span class="red"><strong>Note:<br>
157
        </strong></span>You can configure your CARP-Settings <a href="firewall_virtual_ip.php">here</a>.</span></p>
158
</td>
159 a26686cb Scott Ullrich
</table>
160 c55a8ab9 Holger Bauer
161 a26686cb Scott Ullrich
</td></tr>
162
</table>
163 e2de5461 Scott Ullrich
</div>
164 a26686cb Scott Ullrich
165 c55a8ab9 Holger Bauer
166 a26686cb Scott Ullrich
<?php include("fend.inc"); ?>
167 e2de5461 Scott Ullrich
<script type="text/javascript">
168
NiftyCheck();
169 c96e4db7 Scott Ullrich
Rounded("div#mainlevel","all","#FFF","#eeeeee","smooth");
170 e2de5461 Scott Ullrich
</script>
171
172 a26686cb Scott Ullrich
</body>
173 07bdf973 Bill Marquette
</html>