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