Project

General

Profile

Download (5.51 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
$status = get_carp_status();
38
if($_POST['disablecarp'] <> "") {
39
	if($status == true) {
40
		$carp_counter=find_number_of_created_carp_interfaces();
41
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
42
		for($x=0; $x<$carp_counter; $x++) {
43
			mwexec("/sbin/ifconfig carp{$x} down");
44
			mwexec("/sbin/ifconfig carp{$x} destroy");
45
		}
46
		$savemsg = "{$carp_counter} IPs have been disabled.";
47
	} else {
48
		$savemsg = "CARP has been enabled.";
49
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
50
		interfaces_carp_configure();
51
		interfaces_carp_bring_up_final();
52
	}
53
}
54

    
55
$status = get_carp_status();
56

    
57
$pgtitle = "CARP: Status";
58
include("head.inc");
59

    
60
?>
61

    
62
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
63
<?php include("fbegin.inc"); ?>
64
<p class="pgtitle"><?=$pgtitle?></p>
65
<form action="carp_status.php" method="post">
66
<?php if ($savemsg) print_info_box($savemsg); ?>
67

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

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

    
89
					include("fend.inc");
90
					echo "</body></html>";
91
					exit;
92
				}
93
			}
94
?>
95

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

    
167
			</td>
168
		</tr>
169
	</table>
170
</div>
171

    
172
<meta http-equiv="refresh" content="60;url=<?php print $_SERVER['PHP_SELF']; ?>">
173

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

    
176

    
177
</body>
178
</html>
(2-2/155)