mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-03 21:02:34 +00:00 
			
		
		
		
	update the web page for "node/application status monitoring".
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3894 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -37,9 +37,9 @@ function displayMapper_mon($mapper)
 | 
			
		||||
         $ooe = $ooe%2;
 | 
			
		||||
         echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
         echo "<td><input type='radio' name='plugins' value='$name' /></td>";
 | 
			
		||||
         echo "<td id='$line-0'><a class='description' href='#'>$name</a></td>";
 | 
			
		||||
         echo "<td id='$line-1'>$stat</td>";
 | 
			
		||||
         if(isset($nodemonstatus)) { echo "<td id='$line-2'>Yes</td>";}else {echo "<td id='$line-2'>No</td>";}
 | 
			
		||||
         echo "<td ><a class='description' href='#'>$name</a></td>";
 | 
			
		||||
         echo "<td >$stat</td>";
 | 
			
		||||
         if(isset($nodemonstatus)) { echo "<td >Enabled</td>";}else {echo "<td >Disabled</td>";}
 | 
			
		||||
         echo "   </tr>";
 | 
			
		||||
         $ooe++;
 | 
			
		||||
         $line++;
 | 
			
		||||
@@ -93,6 +93,52 @@ TOS1;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function display_stat_mon_table($args)
 | 
			
		||||
{
 | 
			
		||||
    //create one table to disable or enable node/application monitoring
 | 
			
		||||
    //the argument $args are one array like this:
 | 
			
		||||
    //{ 'xcatmon' => {
 | 
			
		||||
    //      'nodestat' => 'Enabled',
 | 
			
		||||
    //      'appstat' => 'Disabled',
 | 
			
		||||
    //  },
 | 
			
		||||
    //};
 | 
			
		||||
    //
 | 
			
		||||
 | 
			
		||||
    echo '<div style="margin-right: 50px; width:auto; margin-left: 50px">';
 | 
			
		||||
    foreach($args as $key => $value) {
 | 
			
		||||
        $name = $key;
 | 
			
		||||
 | 
			
		||||
        if($value{'nodestat'} == 'Enabled') {
 | 
			
		||||
            $ns_tobe = 'Disable';
 | 
			
		||||
        } else {
 | 
			
		||||
            $ns_tobe = 'Enable';
 | 
			
		||||
        }
 | 
			
		||||
        if($value{'appstat'} == 'Enabled') {
 | 
			
		||||
            $as_tobe = 'Disable';
 | 
			
		||||
        } else {
 | 
			
		||||
            $as_tobe = 'Enable';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    echo "<h3>Node/Application Status Monitoring for $name</h3>";
 | 
			
		||||
echo <<<TOS2
 | 
			
		||||
<table cellspacing="1" class="tabTable" id="tabTable"><tbody>
 | 
			
		||||
<tr class="ListLine0">
 | 
			
		||||
<td>Node Status Application Monitoring</td>
 | 
			
		||||
<td>
 | 
			
		||||
TOS2;
 | 
			
		||||
    insertButtons(array('label'=>$ns_tobe, 'id'=>'node_stat', 'onclick'=>"node_stat_control(\"$name\")"));
 | 
			
		||||
    echo '</td>';
 | 
			
		||||
    echo '</tr>';
 | 
			
		||||
    echo '<tr class="ListLine1">';
 | 
			
		||||
    echo '<td>Application Status Application Monitoring</td>';
 | 
			
		||||
    echo '<td>';
 | 
			
		||||
    insertbuttons(array('label'=>$as_tobe, 'id'=>'app_stat', 'onclick'=>''));
 | 
			
		||||
    echo '</td>';
 | 
			
		||||
    echo '</tr>';
 | 
			
		||||
    echo '</tbody> </table> </div>';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayStatus()
 | 
			
		||||
{
 | 
			
		||||
    //tell the user that the current interface is not done yet...
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								xCAT-UI/monitor/control_node_stat.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								xCAT-UI/monitor/control_node_stat.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * Enable/Disable node_stat_monitor feature for the desired plug-in
 | 
			
		||||
 * this file is invoked by the file "stat_mon.php"
 | 
			
		||||
 * update the table "monitoring",
 | 
			
		||||
 */
 | 
			
		||||
if(!isset($TOPDIR)) { $TOPDIR="/opt/xcat/ui";}
 | 
			
		||||
 | 
			
		||||
require_once "$TOPDIR/lib/security.php";
 | 
			
		||||
require_once "$TOPDIR/lib/functions.php";
 | 
			
		||||
require_once "$TOPDIR/lib/display.php";
 | 
			
		||||
require_once "$TOPDIR/lib/monitor_display.php";
 | 
			
		||||
 | 
			
		||||
$name = $_REQUEST['name'];
 | 
			
		||||
$action = $_REQUEST['action'];
 | 
			
		||||
 | 
			
		||||
//TODO: right now, we can't change the contents of the xcat tables through xcatd
 | 
			
		||||
//if($action == 'enable') {
 | 
			
		||||
//    //chtab name=$name monitoring.nodestatmon='yes'
 | 
			
		||||
//    $xml=docmd("chtab",' ',array("name=$name","monitoring.nodestatmon=\'yes\'"));
 | 
			
		||||
//    if(getXmlErrors($xml, $errors)) {
 | 
			
		||||
//        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
//        exit;
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//}else if($action == 'disable') {
 | 
			
		||||
//    //chtab name=$name monitoring.nodestatmon=''
 | 
			
		||||
//    $xml=docmd("chtab",' ', array("name=$name","monitoring.nodestatmon=\'\'"));
 | 
			
		||||
//    if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
//        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
//        exit;
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
echo "successful";
 | 
			
		||||
?>
 | 
			
		||||
@@ -10,7 +10,65 @@ require_once "$TOPDIR/lib/functions.php";
 | 
			
		||||
require_once "$TOPDIR/lib/display.php";
 | 
			
		||||
require_once "$TOPDIR/lib/monitor_display.php";
 | 
			
		||||
 | 
			
		||||
//get the name of the selected plug-in
 | 
			
		||||
$name = $_REQUEST['name'];
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
function node_stat_control(plugin)
 | 
			
		||||
{
 | 
			
		||||
    //get the label of the button
 | 
			
		||||
    var action = $("#node_stat span").text();
 | 
			
		||||
    if(action=='Enable') {
 | 
			
		||||
        //enable node_stat_monitor
 | 
			
		||||
        $.get("monitor/control_node_stat.php",{name:plugin, action:"enable"},function(data) {
 | 
			
		||||
            if(data=='successful') {
 | 
			
		||||
                //change the label to "Disable"
 | 
			
		||||
                $("#node_stat span").text("Disable");
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }else if(action=='Disable') {
 | 
			
		||||
        //disable node_stat_monitor
 | 
			
		||||
        $.get("monitor/control_node_stat.php",{name:plugin, action:"disable"},function(data) {
 | 
			
		||||
            if(data=='successful') {
 | 
			
		||||
                //change the label to "enable"
 | 
			
		||||
                $("#node_stat span").text("Enable");
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
        //then, change the label to "Enable""
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<?php
 | 
			
		||||
displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php'));
 | 
			
		||||
displayTips(array(
 | 
			
		||||
    "Enable/disable Node/App Status Monitoring by clicking the button",
 | 
			
		||||
    "Click the \"Next\" button to define Events for the desired plug-in"));
 | 
			
		||||
 | 
			
		||||
//get the current status for "node-status-monitor"
 | 
			
		||||
$xml = docmd("monls", ' ', array($name));
 | 
			
		||||
if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
    echo "<p class=Error>",implode(' ',$errors), "</p>";
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
#then, parse the xml data
 | 
			
		||||
foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
    list($n, $stat, $nodemonstatus) = preg_split("/\s+/",$data);
 | 
			
		||||
    if(isset($nodemonstatus)) {
 | 
			
		||||
        $ns = "Enabled";
 | 
			
		||||
    }else {
 | 
			
		||||
        $ns = "Disabled";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
display_stat_mon_table(array("$name"=>
 | 
			
		||||
        array(
 | 
			
		||||
            'nodestat'=>$ns,
 | 
			
		||||
            'appstat'=>'Disabled',  //currently application status monitoring is not supported by xCAT monitor Arch.
 | 
			
		||||
        )));
 | 
			
		||||
 | 
			
		||||
displayStatus();
 | 
			
		||||
 | 
			
		||||
insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>''));
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user