Project

General

Profile

Download (5.48 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
require_once("guiconfig.inc");
30
require_once("xmlparse.inc");
31

    
32
function gentitle_pkg($pgname) {
33
	global $config;
34
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
35
}
36

    
37
unset($interface_arr_cache);
38
unset($carp_interface_count_cache);
39
unset($carp_query);
40
unset($interface_ip_arr_cache);
41

    
42
$status = get_carp_status();
43
if($_POST['disablecarp'] <> "") {
44
	if($status == true) {
45
		$carp_counter=find_number_of_created_carp_interfaces();
46
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
47
		for($x=0; $x<$carp_counter; $x++) {
48
			mwexec("/sbin/ifconfig carp{$x} down");
49
			mwexec("/sbin/ifconfig carp{$x} destroy");
50
		}
51
		$savemsg = "{$carp_counter} IPs have been disabled.";
52
	} else {
53
		$savemsg = "CARP has been enabled.";
54
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
55
		interfaces_carp_configure();
56
	}
57
}
58

    
59
$status = get_carp_status();
60

    
61
$pgtitle = array("Status","CARP");
62
include("head.inc");
63

    
64
?>
65

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

    
170
			</td>
171
		</tr>
172
	</table>
173
</div>
174

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

    
177

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