Project

General

Profile

Download (5.27 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
    carp_status.php
5
    Copyright (C) 2004 Scott Ullrich
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
require_once("guiconfig.inc");
31
require_once("xmlparse.inc");
32

    
33
function gentitle_pkg($pgname) {
34
	global $config;
35
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
36
}
37

    
38
$status = get_carp_status();
39
if($_POST['disablecarp'] <> "") {
40
	if($status == true) {
41
		$carp_counter=find_number_of_created_carp_interfaces();
42
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
43
		for($x=0; $x<$carp_counter; $x++) {
44
			mwexec("/sbin/ifconfig carp{$x} down");
45
			mwexec("/sbin/ifconfig carp{$x} destroy");
46
		}
47
		$savemsg = "{$carp_counter} IPs have been disabled.";
48
	} else {
49
		$savemsg = "CARP has been enabled.";
50
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
51
		interfaces_carp_configure();
52
		interfaces_carp_bringup();
53
	}
54
}
55

    
56
$status = get_carp_status();
57

    
58
$pgtitle = "CARP: Status";
59
include("head.inc");
60

    
61
?>
62

    
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php
65
include("fbegin.inc");
66
?>
67
<p class="pgtitle"><?=$pgtitle?></p>
68
<form action="carp_status.php" method="post">
69
<?php if ($savemsg) print_info_box($savemsg); ?>
70

    
71
<div id="mainarea">
72

    
73
<table width="100%" border="0" cellpadding="0" cellspacing="0">
74
<tr><td>
75
<?php
76
	$tab_array = array();
77
	$tab_array[0] = array("CARP Virtual IPs", false, "/pkg.php?xml=carp.xml");
78
	$tab_array[1] = array("CARP Status", true, "carp_status.php");
79
	$tab_array[2] = array("CARP Settings", false, "/pkg_edit.php?xml=carp_settings.xml&id=0");
80
	display_top_tabs($tab_array);
81
?> 
82
</td></tr>
83
<tr><td class="tabcont">
84

    
85
<?php
86
	if($status == false) {
87
		$carp_enabled = false;
88
		echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Enable Carp\">";
89
	} else {
90
		$carp_enabled = true;
91
		echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"Disable Carp\">";
92
	}
93

    
94
if(!is_array($config['installedpackages']['carp']['config'])) {
95
	echo "</td></tr></table><center><br>Could not locate any defined CARP interfaces.";
96
	echo "</center>";
97

    
98
	include("fend.inc");
99
	echo "</body></html>";
100
	exit;
101
}
102
?>
103

    
104
<p>
105

    
106
<table width="100%" border="0" cellpadding="6" cellspacing="0">
107
</tr>
108
<tr>
109
  <td class="listhdrr"><b><center>Carp Interface</center></b></td>
110
  <td class="listhdrr"><b><center>Virtual IP</center></b></td>
111
  <td class="listhdrr"><b><center>Status</center></b></td>
112
</tr>
113
<?php
114

    
115
if($config['installedpackages']['carp']['config'] <> "")
116
	$carpint=0;
117
	foreach($config['installedpackages']['carp']['config'] as $carp) {
118
		$ipaddress = $carp['ipaddress'];
119
		$premption = $carp['premption'];
120
		$password = $carp['password'];
121
		$netmask = $carp['netmask'];
122
		$vhid = $carp['vhid'];
123
		$advskew = $carp['advskew'];
124
		$pfsync = $carp['pfsync'];
125
		$synciface = $carp['synciface'];
126
		$carp_int = find_carp_interface($ipaddress);
127
		$status = get_carp_interface_status($carp_int);
128
		if(isset($carp['balancing'])) $balancing = "true"; else $balancing = "false";
129
		if(isset($carp['premption'])) $premption = "true"; else $premption = "false";
130
		echo "<tr>";
131
		$align = "valign='middle'";
132
		if($carp_enabled == false) {
133
			$icon = "<img {$align} src='/block.gif'>";
134
			$status = "DISABLED";
135
			$carp_int = "carp" . $carpint;
136
		} else {
137
			if($status == "MASTER") {
138
				$icon = "<img {$align} src='/pass.gif'>";
139
			} else if($status == "BACKUP") {
140
				$icon = "<img {$align} src='/pass_d.gif'>";
141
			} else if($status == "INIT") {
142
				$icon = "<img {$align} src='/log.gif'>";
143
			}
144
		}
145
		echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
146
		echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
147
		echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
148
		echo "</tr>";
149
		$carpint++;
150
	}
151

    
152
?>
153
<tr><td>
154
<center>
155
<?php
156
  echo "<br>pfSync nodes:<br>";
157
  echo "<pre>";
158
  system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
159
  echo "</pre>";
160
?>
161
</center>
162
</td></tr>
163
</table>
164
</td></tr>
165
</table>
166
</div>
167

    
168
<?php include("fend.inc"); ?>
169
<script type="text/javascript">
170
NiftyCheck();
171
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
172
</script>
173

    
174
</body>
175
</html>
176

    
(2-2/127)