Project

General

Profile

Download (5.63 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($status == false) {
85
				$carp_enabled = false;
86
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
87
			} else {
88
				$carp_enabled = true;
89
				echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
90
			}
91

    
92
			if(is_array($config['virtualip']['vip'])) {
93
				foreach($config['virtualip']['vip'] as $carp) {
94
					if ($carp['mode'] == "carp") $carpcount++;
95
				}
96
				if ($carpcount == 0) {
97
					echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
98
					echo "</center>";
99

    
100
					include("fend.inc");
101
					echo "</body></html>";
102
					exit;
103
				}
104
			}
105
?>
106

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

    
178
			</td>
179
		</tr>
180
	</table>
181
</div>
182

    
183
<?php include("fend.inc"); ?>
184

    
185

    
186
</body>
187
</html>
(2-2/205)