Project

General

Profile

Download (6.65 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
                                       	case "carpdev-dhcp":
65
                                       		interface_vip_bring_down($vip);
66
                                       		sleep(1);
67
                                       	break;
68
                               	}
69
                	}
70
        	}
71
		$savemsg = sprintf(gettext("%s IPs have been disabled."), $carp_counter);
72
	} else {
73
		$savemsg = gettext("CARP has been enabled.");
74
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
75
		interfaces_carp_setup();
76
		if(is_array($config['virtualip']['vip'])) {
77
                        $viparr = &$config['virtualip']['vip'];
78
                        foreach ($viparr as $vip) {
79
				switch ($vip['mode']) {
80
					case "carp":
81
						interface_carp_configure($vip);
82
						sleep(1);
83
					break;
84
					case "carpdev-dhcp":
85
						interface_carpdev_configure($vip);
86
						sleep(1);
87
					break;
88
                                }
89
                        }
90
                }
91
	}
92
}
93

    
94
$status = get_carp_status();
95

    
96
$pgtitle = array(gettext("Status"),gettext("CARP"));
97
include("head.inc");
98

    
99
?>
100

    
101
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
102
<?php include("fbegin.inc"); ?>
103
<form action="carp_status.php" method="post">
104
<?php if ($savemsg) print_info_box($savemsg); ?>
105

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

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

    
143
					include("fend.inc");
144
					echo "</body></html>";
145
					exit;
146
				}
147

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

    
187
<p/>
188

    
189
<span class="vexpl">
190
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
191
<br />
192
<?=gettext("You can configure CARP settings"); ?> <a href="pkg_edit.php?xml=carp_settings.xml&id=0"><?=gettext("here"); ?></a>.
193
</span>
194

    
195
<p/>
196

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

    
204
<?php include("fend.inc"); ?>
205

    
206
</body>
207
</html>
(3-3/224)