Project

General

Profile

Download (6.52 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
	pfSense_BUILDER_BINARIES:	/sbin/sysctl	
38
	pfSense_MODULE:	carp
39
*/
40

    
41
require_once("guiconfig.inc");
42

    
43
function gentitle_pkg($pgname) {
44
	global $config;
45
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
46
}
47

    
48
unset($interface_arr_cache);
49
unset($carp_interface_count_cache);
50
unset($interface_ip_arr_cache);
51

    
52
$status = get_carp_status();
53
if($_POST['disablecarp'] <> "") {
54
	if($status == true) {
55
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
56
		if(is_array($config['virtualip']['vip'])) {
57
			$viparr = &$config['virtualip']['vip'];
58
                	foreach ($viparr as $vip) {
59
                               	switch ($vip['mode']) {
60
                                       	case "carp":
61
                                       		interface_vip_bring_down($vip);
62
                                       		sleep(1);
63
                                       	break;
64
                               	}
65
                	}
66
        	}
67
		$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
68
	} else {
69
		$savemsg = gettext("CARP has been enabled.");
70
		if(is_array($config['virtualip']['vip'])) {
71
                        $viparr = &$config['virtualip']['vip'];
72
                        foreach ($viparr as $vip) {
73
				switch ($vip['mode']) {
74
					case "carp":
75
						interface_carp_configure($vip);
76
						sleep(1);
77
					break;
78
					case "ipalias":
79
						if (strstr($vip['interface'], "_vip"))
80
							interface_ipalias_configure($vip);
81
					break;
82
                                }
83
                        }
84
                }
85
		interfaces_carp_setup();
86
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
87
	}
88
}
89

    
90
$status = get_carp_status();
91

    
92
$pgtitle = array(gettext("Status"),gettext("CARP"));
93
include("head.inc");
94

    
95
?>
96

    
97
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
98
<?php include("fbegin.inc"); ?>
99
<form action="carp_status.php" method="post">
100
<?php if ($savemsg) print_info_box($savemsg); ?>
101

    
102
<div id="mainlevel">
103
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
104
		<tr>
105
			<td>
106
<?php
107
			$carpcount = 0;
108
			if(is_array($config['virtualip']['vip'])) {
109
				foreach($config['virtualip']['vip'] as $carp) {
110
					if ($carp['mode'] == "carp") {
111
						$carpcount++;
112
						break;
113
					}
114
				}
115
			}
116
			if($carpcount > 0) {
117
				if($status == false) {
118
					$carp_enabled = false;
119
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Enable Carp") . "\">";
120
				} else {
121
					$carp_enabled = true;
122
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Disable Carp") . "\">";
123
				}
124
			}
125
?>
126

    
127
			<p>
128
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
129
				<tr>
130
					<td class="listhdrr"><b><center><?=gettext("CARP Interface"); ?></center></b></td>
131
					<td class="listhdrr"><b><center><?=gettext("Virtual IP"); ?></center></b></td>
132
					<td class="listhdrr"><b><center><?=gettext("Status"); ?></center></b></td>
133
				</tr>
134
<?php
135
				if ($carpcount == 0) {
136
					echo "</td></tr></table></table></div><center><br>" . gettext("Could not locate any defined CARP interfaces.");
137
					echo "</center>";
138

    
139
					include("fend.inc");
140
					echo "</body></html>";
141
					exit;
142
				}
143

    
144
				if(is_array($config['virtualip']['vip'])) {
145
					foreach($config['virtualip']['vip'] as $carp) {
146
						if ($carp['mode'] != "carp")
147
							continue;
148
						$ipaddress = $carp['subnet'];
149
						$password = $carp['password'];
150
						$netmask = $carp['subnet_bits'];
151
						$vhid = $carp['vhid'];
152
						$advskew = $carp['advskew'];
153
						$advbase = $carp['advbase'];
154
						$carp_int = "{$carp['interface']}_vip{$vhid}";
155
						$status = get_carp_interface_status($carp_int);
156
						echo "<tr>";
157
						$align = "valign='middle'";
158
						if($carp_enabled == false) {
159
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
160
							$status = "DISABLED";
161
						} else {
162
							if($status == "MASTER") {
163
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
164
							} else if($status == "BACKUP") {
165
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
166
							} else if($status == "INIT") {
167
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
168
							}
169
						}
170
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
171
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
172
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
173
						echo "</tr>";
174
					}
175
				}
176
?>
177
			</table>
178
			</td>
179
		</tr>
180
	</table>
181
</div>
182

    
183
<p/>
184

    
185
<span class="vexpl">
186
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
187
<br />
188
<?=gettext("You can configure high availability sync settings"); ?> <a href="system_hasync.php"><?=gettext("here"); ?></a>.
189
</span>
190

    
191
<p/>
192

    
193
<?php
194
	echo "<br>" . gettext("pfSync nodes") . ":<br>";
195
	echo "<pre>";
196
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
197
	echo "</pre>";
198
?>
199

    
200
<?php include("fend.inc"); ?>
201

    
202
</body>
203
</html>
(3-3/249)