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
##|+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
		if (is_array($carp_ints)) {
60
			foreach($carp_ints as $int) {
61
				mwexec("/sbin/ifconfig $int down");
62
				mwexec("/sbin/ifconfig $int destroy");
63
			}
64
		}
65
		$savemsg = "{$carp_counter} IPs have been disabled.";
66
	} else {
67
		$savemsg = "CARP has been enabled.";
68
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
69
		interfaces_carp_setup();
70
	}
71
}
72

    
73
$status = get_carp_status();
74

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

    
78
?>
79

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

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

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

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

    
124
				if(is_array($config['virtualip']['vip'])) {
125
					foreach($config['virtualip']['vip'] as $carp) {
126
						if ($carp['mode'] != "carp") continue;
127
						$ipaddress = $carp['subnet'];
128
						$password = $carp['password'];
129
						$netmask = $carp['subnet_bits'];
130
						$vhid = $carp['vhid'];
131
						$advskew = $carp['advskew'];
132
						$carp_int = find_carp_interface($ipaddress);
133
						$status = get_carp_interface_status($carp_int);
134
						echo "<tr>";
135
						$align = "valign='middle'";
136
						if($carp_enabled == false) {
137
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
138
							$status = "DISABLED";
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
					}
153
				}
154
?>
155
			</table>
156
			</td>
157
		</tr>
158
	</table>
159
</div>
160

    
161
<p/>
162

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

    
169
<p/>
170

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

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

    
180
</body>
181
</html>
(3-3/221)