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
##|+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($carp_query);
51
unset($interface_ip_arr_cache);
52

    
53
$status = get_carp_status();
54
if($_POST['disablecarp'] <> "") {
55
	if($status == true) {
56
		$carp_ints = get_all_carp_interfaces();
57
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
58
		$carp_counter = find_number_of_created_carp_interfaces();
59
		foreach($carp_ints as $int) {
60
			mwexec("/sbin/ifconfig $int down");
61
			mwexec("/sbin/ifconfig $int destroy");
62
		}
63
		$savemsg = "{$carp_counter} IPs have been disabled.";
64
	} else {
65
		$savemsg = "CARP has been enabled.";
66
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
67
		interfaces_carp_setup();
68
	}
69
}
70

    
71
$status = get_carp_status();
72

    
73
$pgtitle = array("Status","CARP");
74
include("head.inc");
75

    
76
?>
77

    
78
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
79
<?php include("fbegin.inc"); ?>
80
<form action="carp_status.php" method="post">
81
<?php if ($savemsg) print_info_box($savemsg); ?>
82

    
83
<div id="mainlevel">
84
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
85
		<tr>
86
			<td>
87
<?php
88
			if(is_array($config['virtualip']['vip'])) {
89
				foreach($config['virtualip']['vip'] as $carp) {
90
					if ($carp['mode'] == "carp") 
91
						$carpcount++;
92
				}
93
			}
94
			if($carpcount > 0) {
95
				if($status == false) {
96
					$carp_enabled = false;
97
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
98
				} else {
99
					$carp_enabled = true;
100
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
101
				}
102
			}
103
?>
104

    
105
			<p>
106
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
107
				<tr>
108
					<td class="listhdrr"><b><center>Carp Interface</center></b></td>
109
					<td class="listhdrr"><b><center>Virtual IP</center></b></td>
110
					<td class="listhdrr"><b><center>Status</center></b></td>
111
				</tr>
112
<?php
113
				if ($carpcount == 0) {
114
					echo "</td></tr></table></table></div><center><br>Could not locate any defined CARP interfaces.";
115
					echo "</center>";
116

    
117
					include("fend.inc");
118
					echo "</body></html>";
119
					exit;
120
				}
121

    
122
				if(is_array($config['virtualip']['vip'])) {
123
					$carpint=0;
124
					foreach($config['virtualip']['vip'] as $carp) {
125
						if ($carp['mode'] != "carp") continue;
126
						$ipaddress = $carp['subnet'];
127
						$password = $carp['password'];
128
						$netmask = $carp['subnet_bits'];
129
						$vhid = $carp['vhid'];
130
						$advskew = $carp['advskew'];
131
						$carp_int = find_carp_interface($ipaddress);
132
						$status = get_carp_interface_status($carp_int);
133
						echo "<tr>";
134
						$align = "valign='middle'";
135
						if($carp_enabled == false) {
136
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
137
							$status = "DISABLED";
138
							$carp_int = "carp" . $carpint;
139
						} else {
140
							if($status == "MASTER") {
141
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
142
							} else if($status == "BACKUP") {
143
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
144
							} else if($status == "INIT") {
145
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
146
							}
147
						}
148
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
149
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
150
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
151
						echo "</tr>";
152
						$carpint++;
153
					}
154
				}
155
?>
156
			</table>
157
			</td>
158
		</tr>
159
	</table>
160
</div>
161

    
162
<p/>
163

    
164
<span class="vexpl">
165
<span class="red"><strong>Note:</strong></span>
166
<br />
167
You can configure CARP settings <a href="pkg_edit.php?xml=carp_settings.xml&id=0">here</a>.
168
</span>
169

    
170
<p/>
171

    
172
<?php
173
	echo "<br>pfSync nodes:<br>";
174
	echo "<pre>";
175
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
176
	echo "</pre>";
177
?>
178

    
179
<?php include("fend.inc"); ?>
180

    
181
</body>
182
</html>
(3-3/215)