Location: PHPKode > projects > SCOP Heartbeat Administration interface > scop-2.0/html/scop/maint/maint.php

<?
$l = $_GET['l'];
global $meta;
$meta = "<meta http-equiv=\"refresh\" content=\"10;url=maint.php?srcfile=ldirectord&action=modrealweight&l=$l\">";

// maint.php : All code hear is to allow the maintenance of real servers by allowing you to take them on or off line
// It needs to display both required AND acctual status.
// Copyright Loadbalancer.org Limited all source code protected by the GPL with NO WARRANTY.

include ("../inc/header.inc");
include ("../inc/functions.inc");


# This code opens a file, reads it into an array and then writes it back to a file.

If ($srcfile=="ldirectord") {

	parse_status_file(); // Get the actual live status from ipvsadm
	global $REALWEIGHT_stat,$VIRTUALWEIGHT_stat,$REALACTIVECONS_stat;
	parse_config_file(); // Read the ldirectord.cf file and setup the global variables
	global $REALWEIGHT,$v,$r,$VIRTUAL,$VIRTUAL_LABEL,$VIRTUAL_WEIGHT,$REAL_LABEL,$WRITEFILE;



	if ($action=="modrealweight") {

		if ($subaction=="change") {

			$WRITEFILE=TRUE;
			$realserver = $REAL_LABEL[$v][$r];

			if ($REALWEIGHT[$v][$r]==0) {
				$REALWEIGHT[$v][$r]=1;
				SCOP_log("Maintenance : Real server $realserver changed to ONLINE for VIP $VIRTUAL_LABEL[$v]");
			}
			else {

				$REALWEIGHT[$v][$r]=0;
				SCOP_log("Maintenance : Real server $realserver changed to OFFLINE for VIP $VIRTUAL_LABEL[$v]");

			}
		}

		// Need to parse the live status as well as requested for comparison.


		//echo "<h2>Modify The Status Of Real Servers</h2>";
		$trans="16a";
		$txt = "${$l.$trans}";

		$trans="4";
		$a4 = "${$l.$trans}"

?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=maint&l=<?=$l?>"><?=$a4?></a> &gt; <?=$txt?></h1>
<div class="border">

<?

		$trans="43";
		$a43 = "${$l.$trans}";
		$trans="21";
		$a21 = "${$l.$trans}";
		$trans="44";
		$a44 = "${$l.$trans}";
		$trans="45";
		$a45 = "${$l.$trans}";
		$trans="46";
		$a46 = "${$l.$trans}";
		$trans="47";
		$a47 = "${$l.$trans}";
		$trans="48";
		$a48 = "${$l.$trans}";
		$trans="49";
		$a49 = "${$l.$trans}";
		$trans="50";
		$a50 = "${$l.$trans}";
		$trans="51";
		$a51 = "${$l.$trans}";
		$trans="52";
		$a52 = "${$l.$trans}";
		$trans="55";
		$a55 = "${$l.$trans}";


		//echo "</br>Taking a server offline will change its weight to 0, and the weighted least connection algorithm will no longer use this server.<BR>This is ideal if you need to perform maintenance on a server in the cluster. </br>";
		//echo "When you bring it back online the weight is set to 1. </br>";

		echo "<FORM method=\"post\" action=\"maint.php?srcfile=ldirectord&action=modrealweight&t=$t\"> <center><INPUT type=\"submit\" value=\"$a55\" name=\"go\" ></center></form><br />";


		echo "<table class=\"datagrid\" align=\"center\" summary=\"server status\">";
		echo "<th><b> $a43 </th><th><i> $a21 </i></b></th><th> <b> $a44 </b></th><th><center><i> $a45 </i></center></th><th><center><b> $a46  </b></center></th><th><center><b> $a47 </b></center></th><th><center> $a48 </th> " ;
			?><tr><td colspan="7" class="sep2"></td></tr><?

		for ( $i=1; $i<count($VIRTUAL); $i++) { // Display the current info for each virtual server
			// get the total cons
				$REALVIPACTIVCONS = 0;
				for ( $b=0; $b<count($REAL[$i]); $b++) {
				  $REALVIPACTIVCONS = $REALVIPACTIVCONS + $REALACTIVECONS_stat[$i][$b] ;
				}
			//First display the Virtual server info
			echo "<tr><th><b> VIP $i </th><th><i>$VIRTUAL_LABEL[$i]</i></b></th><th><b> $VIRTUAL[$i] </b></th><th><center><i> $REALVIPACTIVCONS </i></center></th><th><center><b>  </b></center></th><th><center><b> </b></center></th><th><center> " . active($VIRTUALWEIGHT_stat[$i]) . "</th></tr>" ;
?><tr><td colspan="7" class="sep1"></td></tr><?
			//echo "</table><table width=\"60%\">";

			//for ( $b=0; $b<count($REAL[$i]); $b++) {
			for ( $b=count($REAL[$i])-1; $b>-1; $b--) {
				$x=$b+1;
				echo "<tr><td><center>RIP <b>$x</b></center> </td><td><i><center> " . $REAL_LABEL[$i][$b] . " </center> </i></td><td><center><b> " . $REAL[$i][$b] . "</b></center></td><td><center><i> " . $REALACTIVECONS_stat[$i][$b] . "</i></center></td>";
				if ($REALWEIGHT[$i][$b]==0) {
					echo "<td><b><center><font color=\"red\" >$a50 (<i>" . $REALWEIGHT[$i][$b] . "</i>)</font></center></b></td><td><center><a href=\"maint.php?srcfile=ldirectord&action=modrealweight&subaction=change&v=$i&r=$b&t=$t\"> $a52 </a></center></td><td><center>"  . active($REALWEIGHT_stat[$i][$b]) . "</center></td></tr>";
				}
				else {
					echo "<td><b><center><font color=\"#0ef42d\"> $a49 (<i><a href=\"../config/display.php?srcfile=ldirectord&action=modreal&subaction=modify&v=$i&r=$b&l=$l\">" . $REALWEIGHT[$i][$b] . "</a></i>)</font></center></b></td><td><center><a href=\"maint.php?srcfile=ldirectord&action=modrealweight&subaction=change&v=$i&r=$b&t=$t\"> $a51 </a></center></td><td><center> "  . active($REALWEIGHT_stat[$i][$b]) . " </center></td></tr>";
				}
			?><tr><td colspan="7" class="sep1"></td></tr><?
			}

		}
		echo "</table>";
?>
<hr class="sep1">


</div>
<div class="bottom"><span>-----</span></div>
</div>
<?
		//echo "</br>NB. When you take a server offline make sure the current sessions have finished before re-booting a Real Server etc. </br>";
	}
	if ($WRITEFILE==TRUE) {
		# open a new file
		write_config_file();
	}






}



include ("../inc/footer.inc");
?>


Return current item: SCOP Heartbeat Administration interface