Project

General

Profile

Download (7.25 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / carp_status.php @ a1b66bec

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_MODULE:	carp
38
*/
39

    
40
require_once("guiconfig.inc");
41
require_once("globals.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
$status = intval($status);
54
if($_POST['carp_maintenancemode'] <> "") {
55
	interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"]));
56
}
57
if($_POST['disablecarp'] <> "") {
58
	if($status > 0) {
59
		set_single_sysctl('net.inet.carp.allow', '0');
60
		if(is_array($config['virtualip']['vip'])) {
61
			$viparr = &$config['virtualip']['vip'];
62
			foreach ($viparr as $vip) {
63
				switch ($vip['mode']) {
64
				case "carp":
65
					interface_vip_bring_down($vip);
66
					sleep(1);
67
					break;
68
				}
69
			}
70
		}
71
		$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
72
		$status = 0;
73
	} else {
74
		$savemsg = gettext("CARP has been enabled.");
75
		if(is_array($config['virtualip']['vip'])) {
76
			$viparr = &$config['virtualip']['vip'];
77
			foreach ($viparr as $vip) {
78
				switch ($vip['mode']) {
79
				case "carp":
80
					interface_carp_configure($vip);
81
					sleep(1);
82
					break;
83
				}
84
				case 'ipalias':
85
					if (strpos($vip['interface'], '_vip'))
86
						interface_ipalias_configure($vip);
87
					break;
88
			}
89
		}
90
		interfaces_sync_setup();
91
		set_single_sysctl('net.inet.carp.allow', '1');
92
		$status = 1;
93
	}
94
}
95

    
96
$carp_detected_problems = ((get_single_sysctl("net.inet.carp.demotion")) > 0);
97

    
98
$pgtitle = array(gettext("Status"),gettext("CARP"));
99
$shortcut_section = "carp";
100
include("head.inc");
101

    
102
?>
103

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

    
109
<?PHP	if ($carp_detected_problems) print_info_box(gettext("CARP has detected a problem and this unit has been demoted to BACKUP status.") . "<br />" . gettext("Check link status on all interfaces with configured CARP VIPs.")); ?>
110

    
111

    
112
<div id="mainlevel">
113
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="carp status">
114
		<tr>
115
			<td>
116
<?php
117
			$carpcount = 0;
118
			if(is_array($config['virtualip']['vip'])) {
119
				foreach($config['virtualip']['vip'] as $carp) {
120
					if ($carp['mode'] == "carp") {
121
						$carpcount++;
122
						break;
123
					}
124
				}
125
			}
126
			if($carpcount > 0) {
127
				if($status > 0) {
128
					$carp_enabled = true;
129
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Temporarily Disable CARP") . "\" />";
130
				} else {
131
					$carp_enabled = false;
132
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Enable CARP") . "\" />";
133
				}
134
				if(isset($config["virtualip_carp_maintenancemode"])) {
135
					echo "<input type=\"submit\" name=\"carp_maintenancemode\" id=\"carp_maintenancemode\" value=\"" . gettext("Leave Persistent CARP Maintenance Mode") . "\" />";
136
				} else {
137
					echo "<input type=\"submit\" name=\"carp_maintenancemode\" id=\"carp_maintenancemode\" value=\"" . gettext("Enter Persistent CARP Maintenance Mode") . "\" />";
138
				}
139
			}
140
?>
141

    
142
			<br/><br/>
143
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="results">
144
				<tr>
145
					<td class="listhdrr" align="center"><?=gettext("CARP Interface"); ?></td>
146
					<td class="listhdrr" align="center"><?=gettext("Virtual IP"); ?></td>
147
					<td class="listhdrr" align="center"><?=gettext("Status"); ?></td>
148
				</tr>
149
<?php
150
				if ($carpcount == 0) {
151
					echo "</table></td></tr></table></div></form><center><br />" . gettext("Could not locate any defined CARP interfaces.");
152
					echo "</center>";
153

    
154
					include("fend.inc");
155
					echo "</body></html>";
156
					return;
157
				}
158
				if(is_array($config['virtualip']['vip'])) {
159
					foreach($config['virtualip']['vip'] as $carp) {
160
						if ($carp['mode'] != "carp")
161
							continue;
162
						$ipaddress = $carp['subnet'];
163
						$password = $carp['password'];
164
						$netmask = $carp['subnet_bits'];
165
						$vhid = $carp['vhid'];
166
						$advskew = $carp['advskew'];
167
						$advbase = $carp['advbase'];
168
						$status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");
169
						echo "<tr>";
170
						$align = "style=\"vertical-align:middle\"";
171
						if($carp_enabled == false) {
172
							$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_block.gif\" alt=\"disabled\" />";
173
							$status = "DISABLED";
174
						} else {
175
							if($status == "MASTER") {
176
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_pass.gif\" alt=\"master\" />";
177
							} else if($status == "BACKUP") {
178
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_pass_d.gif\" alt=\"backup\" />";
179
							} else if($status == "INIT") {
180
								$icon = "<img {$align} src=\"/themes/".$g['theme']."/images/icons/icon_log.gif\" alt=\"init\" />";
181
							}
182
						}
183
						echo "<td class=\"listlr\" align=\"center\">" . convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid} &nbsp;</td>";
184
						echo "<td class=\"listlr\" align=\"center\">" . $ipaddress . "&nbsp;</td>";
185
						echo "<td class=\"listlr\" align=\"center\">{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
186
						echo "</tr>";
187
					}
188
				}
189
?>
190
			</table>
191
			</td>
192
		</tr>
193
	</table>
194
</div>
195
</form>
196

    
197
<p class="vexpl">
198
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
199
<br />
200
<?=gettext("You can configure high availability sync settings"); ?> <a href="system_hasync.php"><?=gettext("here"); ?></a>.
201
</p>
202

    
203
<?php
204
	echo "<br />" . gettext("pfSync nodes") . ":<br />";
205
	echo "<pre>";
206
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
207
	echo "</pre>";
208
?>
209

    
210
<?php include("fend.inc"); ?>
211

    
212
</body>
213
</html>
(3-3/256)