Projet

Général

Profil

Télécharger (7,13 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / carp_status.php @ 9c296826

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
			}
85
		}
86
		interfaces_carp_setup();
87
		set_single_sysctl('net.inet.carp.allow', '1');
88
		$status = 1;
89
	}
90
}
91

    
92
$carp_detected_problems = ((get_single_sysctl("net.inet.carp.demotion")) > 0);
93

    
94
$pgtitle = array(gettext("Status"),gettext("CARP"));
95
$shortcut_section = "carp";
96
include("head.inc");
97

    
98
?>
99

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

    
105
<?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.")); ?>
106

    
107

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

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

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

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

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

    
206
<?php include("fend.inc"); ?>
207

    
208
</body>
209
</html>
(3-3/256)