Project

General

Profile

Download (5.18 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
65
include("fbegin.inc");
66
?>
67
<p class="pgtitle"><?=$pgtitle?></p>
68
<form action="carp_status.php" method="post">
69
<?php if ($savemsg) print_info_box($savemsg); ?>
70

    
71
<div id="mainlevel">
72
<table width="100%" border="0" cellpadding="0" cellspacing="0">
73
<tr><td class="tabcont">
74

    
75
<?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
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
	echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
90
	echo "</center>";
91

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

    
99
<p>
100

    
101
<table width="100%" border="0" cellpadding="6" cellspacing="0">
102
</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
if(is_array($config['virtualip']['vip'])) {
111
	$carpint=0;
112
	foreach($config['virtualip']['vip'] as $carp) {
113
		if ($carp['mode'] != "carp") continue;
114
		$ipaddress = $carp['subnet'];
115
		$password = $carp['password'];
116
		$netmask = $carp['subnet_bits'];
117
		$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
			$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
125
			$status = "DISABLED";
126
			$carp_int = "carp" . $carpint;
127
		} else {
128
			if($status == "MASTER") {
129
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
130
			} else if($status == "BACKUP") {
131
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
132
			} else if($status == "INIT") {
133
				$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
134
			}
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
}
143
?>
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

    
154
</td></tr>
155
<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
</table>
160

    
161
</td></tr>
162
</table>
163
</div>
164

    
165

    
166
<?php include("fend.inc"); ?>
167
<script type="text/javascript">
168
NiftyCheck();
169
Rounded("div#mainlevel","all","#FFF","#eeeeee","smooth");
170
</script>
171

    
172
</body>
173
</html>
(2-2/143)