Project

General

Profile

Download (5.68 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
##|+PRIV
30
##|*IDENT=page-status-carp
31
##|*NAME=Status: CARP page
32
##|*DESCR=Allow access to the 'Status: CARP' page.
33
##|*MATCH=carp_status.php*
34
##|-PRIV
35

    
36

    
37
require_once("guiconfig.inc");
38
require_once("xmlparse.inc");
39

    
40
function gentitle_pkg($pgname) {
41
	global $config;
42
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
43
}
44

    
45
unset($interface_arr_cache);
46
unset($carp_interface_count_cache);
47
unset($carp_query);
48
unset($interface_ip_arr_cache);
49

    
50
$status = get_carp_status();
51
if($_POST['disablecarp'] <> "") {
52
	if($status == true) {
53
		$carp_counter=find_number_of_created_carp_interfaces();
54
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
55
		for($x=0; $x<$carp_counter; $x++) {
56
			mwexec("/sbin/ifconfig carp{$x} down");
57
			mwexec("/sbin/ifconfig carp{$x} destroy");
58
		}
59
		$savemsg = "{$carp_counter} IPs have been disabled.";
60
	} else {
61
		$savemsg = "CARP has been enabled.";
62
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
63
		interfaces_carp_configure();
64
	}
65
}
66

    
67
$status = get_carp_status();
68

    
69
$pgtitle = array("Status","CARP");
70
include("head.inc");
71

    
72
?>
73

    
74
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
75
<?php include("fbegin.inc"); ?>
76
<form action="carp_status.php" method="post">
77
<?php if ($savemsg) print_info_box($savemsg); ?>
78

    
79
<div id="mainlevel">
80
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
81
		<tr>
82
			<td class="tabcont">
83
<?php
84
			if(is_array($config['virtualip']['vip'])) {
85
				foreach($config['virtualip']['vip'] as $carp) {
86
					if ($carp['mode'] == "carp") 
87
						$carpcount++;
88
				}
89
			}
90
			if($carpcount > 0) {
91
				if($status == false) {
92
					$carp_enabled = false;
93
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
94
				} else {
95
					$carp_enabled = true;
96
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
97
				}
98
			}
99
?>
100

    
101
			<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
<?php
109
				if ($carpcount == 0) {
110
					echo "</td></tr></table></table></div><center><br>Could not locate any defined CARP interfaces.";
111
					echo "</center>";
112

    
113
					include("fend.inc");
114
					echo "</body></html>";
115
					exit;
116
				}
117

    
118
				if(is_array($config['virtualip']['vip'])) {
119
					$carpint=0;
120
					foreach($config['virtualip']['vip'] as $carp) {
121
						if ($carp['mode'] != "carp") continue;
122
						$ipaddress = $carp['subnet'];
123
						$password = $carp['password'];
124
						$netmask = $carp['subnet_bits'];
125
						$vhid = $carp['vhid'];
126
						$advskew = $carp['advskew'];
127
						$carp_int = find_carp_interface($ipaddress);
128
						$status = get_carp_interface_status($carp_int);
129
						echo "<tr>";
130
						$align = "valign='middle'";
131
						if($carp_enabled == false) {
132
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
133
							$status = "DISABLED";
134
							$carp_int = "carp" . $carpint;
135
						} else {
136
							if($status == "MASTER") {
137
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
138
							} else if($status == "BACKUP") {
139
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
140
							} else if($status == "INIT") {
141
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
142
							}
143
						}
144
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
145
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
146
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
147
						echo "</tr>";
148
						$carpint++;
149
					}
150
				}
151
?>
152
				<tr>
153
					<td>
154
						<center>
155
<?php
156
						echo "<br>pfSync nodes:<br>";
157
						echo "<pre>";
158
						system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
159
						echo "</pre>";
160
?>
161
						</center>
162
					</td>
163
				</tr>
164
				<tr>
165
					<td colspan="4">
166
						<p>
167
						<span class="vexpl">
168
						<span class="red">
169
						<strong>
170
						Note:
171
        				</strong>
172
						</span>
173
						<br />
174
						You can configure CARP settings <a href="pkg_edit.php?xml=carp_settings.xml&id=0">here</a>.
175
						</span>
176
						</p>
177
					</td>
178
				</tr>
179
			</table>
180

    
181
			</td>
182
		</tr>
183
	</table>
184
</div>
185

    
186
<?php include("fend.inc"); ?>
187

    
188

    
189
</body>
190
</html>
(2-2/210)