Ticket #1023. Correct the widget code bringing it full speed with latest carp code.

This commit is contained in:
Ermal 2010-11-23 12:47:27 +00:00
parent 83ae810386
commit 108cfddf3e
3 changed files with 9 additions and 11 deletions

View File

@ -339,11 +339,8 @@ function convert_ip_to_network_format($ip, $subnet) {
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
/* basically cache the contents of ifconfig statement
to speed up this routine */
global $carp_query;
if($carp_query == "")
$carp_query = split("\n", `/sbin/ifconfig $carpinterface | grep carp`);
$carp_query = "";
exec("/sbin/ifconfig $carpinterface | /usr/bin/grep -v grep | /usr/bin/grep carp:", $carp_query);
foreach($carp_query as $int) {
if(stristr($int, "MASTER"))
return "MASTER";

View File

@ -4,4 +4,4 @@
$carp_status_title = "Carp Status";
$carp_status_title_link = "carp_status.php";
?>
?>

View File

@ -37,13 +37,14 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
if(is_array($config['virtualip']['vip'])) {
$carpint=0;
foreach($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp") continue;
if ($carp['mode'] != "carp")
continue;
$ipaddress = $carp['subnet'];
$password = $carp['password'];
$netmask = $carp['subnet_bits'];
$netmask = $carp['subnet_bits'];
$vhid = $carp['vhid'];
$advskew = $carp['advskew'];
$carp_int = find_carp_interface($ipaddress);
$carp_int = "vip{$vhid}";
$status = get_carp_interface_status($carp_int);
?>
<tr>
@ -54,7 +55,7 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
</td>
<td width="70%" class="listr">
<?php
if($status == "MASTER") {
if($status == "MASTER") {
echo "<img src='/themes/".$g['theme']."/images/icons/icon_pass.gif' title=\"$status\">";
} else if($status == "BACKUP") {
echo "<img src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif' title=\"$status\">";
@ -73,4 +74,4 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
<?php
}
?>
</table>
</table>