Projet

Général

Profil

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

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

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

    
89
$status = get_carp_status();
90

    
91
$carp_detected_problems = (array_pop(get_sysctl("net.inet.carp.demotion")) > 0);
92

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

    
97
?>
98

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

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

    
106

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

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

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

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

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

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

    
207
</body>
208
</html>
(3-3/255)