Project

General

Profile

Download (5.54 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} delete");
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
		interfaces_carp_bring_up_final();
57
	}
58
}
59

    
60
$status = get_carp_status();
61

    
62
$pgtitle = "CARP: Status";
63
include("head.inc");
64

    
65
?>
66

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

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

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

    
94
					include("fend.inc");
95
					echo "</body></html>";
96
					exit;
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(is_array($config['virtualip']['vip'])) {
110
					$carpint=0;
111
					foreach($config['virtualip']['vip'] as $carp) {
112
						if ($carp['mode'] != "carp") continue;
113
						$ipaddress = $carp['subnet'];
114
						$password = $carp['password'];
115
						$netmask = $carp['subnet_bits'];
116
						$vhid = $carp['vhid'];
117
						$advskew = $carp['advskew'];
118
						$carp_int = find_carp_interface($ipaddress);
119
						$status = get_carp_interface_status($carp_int);
120
						echo "<tr>";
121
						$align = "valign='middle'";
122
						if($carp_enabled == false) {
123
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
124
							$status = "DISABLED";
125
							$carp_int = "carp" . $carpint;
126
						} else {
127
							if($status == "MASTER") {
128
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
129
							} else if($status == "BACKUP") {
130
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
131
							} else if($status == "INIT") {
132
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
133
							}
134
						}
135
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
136
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
137
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
138
						echo "</tr>";
139
						$carpint++;
140
					}
141
				}
142
?>
143
				<tr>
144
					<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
					</td>
154
				</tr>
155
				<tr>
156
					<td colspan="4">
157
						<p>
158
						<span class="vexpl">
159
						<span class="red">
160
						<strong>
161
						Note:
162
        				</strong>
163
						</span>
164
						<br />
165
						You can configure CARP settings <a href="pkg_edit.php?xml=carp_settings.xml&id=0">here</a>.
166
						</span>
167
						</p>
168
					</td>
169
				</tr>
170
			</table>
171

    
172
			</td>
173
		</tr>
174
	</table>
175
</div>
176

    
177
<?php include("fend.inc"); ?>
178

    
179

    
180
</body>
181
</html>
(2-2/174)