Project

General

Profile

Download (5.51 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/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
require_once("guiconfig.inc");
31
require_once("xmlparse.inc");
32

    
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

    
58
$pgtitle = "CARP: Status";
59
include("head.inc");
60

    
61
?>
62

    
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php include("fbegin.inc"); ?>
65
<p class="pgtitle"><?=$pgtitle?></p>
66
<form action="carp_status.php" method="post">
67
<?php if ($savemsg) print_info_box($savemsg); ?>
68

    
69
<div id="mainlevel">
70
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
71
		<tr>
72
			<td class="tabcont">
73
<?php
74
			if($status == false) {
75
				$carp_enabled = false;
76
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
77
			} else {
78
				$carp_enabled = true;
79
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
80
			}
81

    
82
			if(is_array($config['virtualip']['vip'])) {
83
				foreach($config['virtualip']['vip'] as $carp) {
84
					if ($carp['mode'] == "carp") $carpcount++;
85
				}
86
				if ($carpcount == 0) {
87
					echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
88
					echo "</center>";
89

    
90
					include("fend.inc");
91
					echo "</body></html>";
92
					exit;
93
				}
94
			}
95
?>
96

    
97
			<p>
98
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
99
				<tr>
100
					<td class="listhdrr"><b><center>Carp Interface</center></b></td>
101
					<td class="listhdrr"><b><center>Virtual IP</center></b></td>
102
					<td class="listhdrr"><b><center>Status</center></b></td>
103
				</tr>
104
<?php
105
				if(is_array($config['virtualip']['vip'])) {
106
					$carpint=0;
107
					foreach($config['virtualip']['vip'] as $carp) {
108
						if ($carp['mode'] != "carp") continue;
109
						$ipaddress = $carp['subnet'];
110
						$password = $carp['password'];
111
						$netmask = $carp['subnet_bits'];
112
						$vhid = $carp['vhid'];
113
						$advskew = $carp['advskew'];
114
						$carp_int = find_carp_interface($ipaddress);
115
						$status = get_carp_interface_status($carp_int);
116
						echo "<tr>";
117
						$align = "valign='middle'";
118
						if($carp_enabled == false) {
119
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
120
							$status = "DISABLED";
121
							$carp_int = "carp" . $carpint;
122
						} else {
123
							if($status == "MASTER") {
124
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
125
							} else if($status == "BACKUP") {
126
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
127
							} else if($status == "INIT") {
128
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
129
							}
130
						}
131
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
132
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
133
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
134
						echo "</tr>";
135
						$carpint++;
136
					}
137
				}
138
?>
139
				<tr>
140
					<td>
141
						<center>
142
<?php
143
						echo "<br>pfSync nodes:<br>";
144
						echo "<pre>";
145
						system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
146
						echo "</pre>";
147
?>
148
						</center>
149
					</td>
150
				</tr>
151
				<tr>
152
					<td colspan="4">
153
						<p>
154
						<span class="vexpl">
155
						<span class="red">
156
						<strong>
157
						Note:
158
        				</strong>
159
						</span>
160
						<br />
161
						You can configure your CARP-Settings <a href="firewall_virtual_ip.php">here</a>.
162
						</span>
163
						</p>
164
					</td>
165
				</tr>
166
			</table>
167

    
168
			</td>
169
		</tr>
170
	</table>
171
</div>
172

    
173
<meta http-equiv="refresh" content="60;url=<?php print $_SERVER['PHP_SELF']; ?>">
174

    
175
<?php include("fend.inc"); ?>
176

    
177

    
178
</body>
179
</html>
(2-2/146)