The code for "define events/performance" and "monitor setup" is here.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3990 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -315,12 +315,106 @@ padding:10px 2px;
 | 
			
		||||
	margin: 0;
 | 
			
		||||
	padding: 0;
 | 
			
		||||
        font-size: 8pt;
 | 
			
		||||
	paddint-right: 0;
 | 
			
		||||
	padding-right: 0;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ositree {
 | 
			
		||||
    float: left;
 | 
			
		||||
    width: auto;
 | 
			
		||||
    min-height: 255px;
 | 
			
		||||
    border-right: 1px dotted #555;
 | 
			
		||||
}
 | 
			
		||||
    min-width: 130px;
 | 
			
		||||
    /*display: none;*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#tips  {
 | 
			
		||||
    margin-right: 10px;
 | 
			
		||||
    margin-left: 10px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    width: 900px;
 | 
			
		||||
    text-align: left;
 | 
			
		||||
    display: block;
 | 
			
		||||
    border-bottom: 1px dotted #555;
 | 
			
		||||
    /*display: none;*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#monlist_table {
 | 
			
		||||
    margin-right: 30px;
 | 
			
		||||
    margin-left: 30px;
 | 
			
		||||
    width: 850px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    display: block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#condresp {
 | 
			
		||||
    width: 770px;
 | 
			
		||||
    margin: 10px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    display: block;
 | 
			
		||||
    border-bottom: 1px dotted #555;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#assocaition {
 | 
			
		||||
    margin: 10px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    float:left;
 | 
			
		||||
    display: block;
 | 
			
		||||
    width: 720px;
 | 
			
		||||
}
 | 
			
		||||
#avail_cond {
 | 
			
		||||
    width: 275px;
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    background-color: #ffee33;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#avail_cond tbody {
 | 
			
		||||
    height: 640px;
 | 
			
		||||
    overflow-y: scroll;
 | 
			
		||||
    overflow-x: hide;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#condition .ui-selecting {background: #FECA40;}
 | 
			
		||||
#condition .ui-selected { background: #F39814; color: white; }
 | 
			
		||||
#condition {list-style-type: none; margin: 0; padding: 0;}
 | 
			
		||||
 | 
			
		||||
#avail_resp {
 | 
			
		||||
    width: 425px;
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    background-color: #eeffee;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#avail_resp tbody {
 | 
			
		||||
    height: 640px;
 | 
			
		||||
    overflow-y: scroll;
 | 
			
		||||
    overflow-x: hide;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#monsetting_tips {
 | 
			
		||||
    width: 888px;
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
    float: left;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#rmcSrcList {
 | 
			
		||||
    width: 420px;
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    background-color:silver;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#rmcScrAttr {
 | 
			
		||||
    width: 420px;
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
    float: left;
 | 
			
		||||
    background-color:silver;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -369,8 +369,10 @@ function node_stat_control(plugin)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function goto_next()
 | 
			
		||||
//TODO: change the function name! it's too silly now!
 | 
			
		||||
{
 | 
			
		||||
    var str = location.href;
 | 
			
		||||
    //TODO:one bug is here.
 | 
			
		||||
    var plugin=str.slice(str.indexOf("name")+5);//get the argument from "?name=xxxxx"
 | 
			
		||||
    if(plugin == "rmcmon") {
 | 
			
		||||
        loadMainPage("monitor/rmc_event_define.php");
 | 
			
		||||
@@ -381,5 +383,52 @@ function goto_next()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function mkCondResp()
 | 
			
		||||
{
 | 
			
		||||
    //get the name of the selected condition
 | 
			
		||||
    //then, get the response in "checked" status
 | 
			
		||||
    //then, run the command "mkcondresp"
 | 
			
		||||
    var cond_val = $('input[@name=conditions][@checked]').val();
 | 
			
		||||
    if(cond_val) {
 | 
			
		||||
        //get the response in "checked" status
 | 
			
		||||
        var resps_obj = $('input[@name=responses][@checked]');
 | 
			
		||||
        if(resps_obj) {
 | 
			
		||||
            $.each(resps_obj,function(i,n) {
 | 
			
		||||
                //i is the index
 | 
			
		||||
                //n is the content
 | 
			
		||||
                //TODO:add one new php file to handle "mkcondresp" command
 | 
			
		||||
                $.get("monitor/makecondresp.php", {cond: cond_val, resp: n.value}, function(data) {
 | 
			
		||||
                    $("#devstatus").html(data);
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
        $("#association").load("monitor/updateCondRespTable.php");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function showRMCAttrib()
 | 
			
		||||
{
 | 
			
		||||
    var class_val = $('input[@name=classGrp][@checked]').val();
 | 
			
		||||
    if(class_val) {
 | 
			
		||||
        $.get("monitor/rmc_resource_attr.php", {name: class_val}, function(data) {
 | 
			
		||||
            $("#rmcScrAttr").html(data);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function monsetupAction(plugin, action_val)
 | 
			
		||||
{
 | 
			
		||||
    //plugin = the name of plugin
 | 
			
		||||
    //action = "start" or "stop" or "restart"
 | 
			
		||||
    $.get("monitor/setup.php", {name: plugin, action: action_val}, function(data) {
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
       $.get("monitor/updateMonList.php", {}, function(data) {
 | 
			
		||||
           $("#monlist").html(data);
 | 
			
		||||
       });
 | 
			
		||||
       
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// load progress bar
 | 
			
		||||
myBar.loaded('xcat.js');
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,18 @@ function displayMapper_mon($mapper)
 | 
			
		||||
         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 "<td>";
 | 
			
		||||
         $name_str = "\"$name\"";
 | 
			
		||||
         if($stat == "monitored") {
 | 
			
		||||
             $act_str = "\"stop\"";
 | 
			
		||||
             insertButtons(array('label'=>'Stop', 'id'=>'stop', 'onclick'=>"monsetupAction($name_str, $act_str)"));
 | 
			
		||||
             $act_str = "\"restart\"";
 | 
			
		||||
             insertButtons(array('label'=>'Restart', 'id'=>'restart', 'onclick'=>"monsetupAction($name_str, $act_str)"));
 | 
			
		||||
         }else {
 | 
			
		||||
             $act_str = "\"start\"";
 | 
			
		||||
             insertButtons(array('label' => 'Start', 'id'=>'start', 'onclick' => "monsetupAction($name_str, $act_str)"));
 | 
			
		||||
         }
 | 
			
		||||
         echo "</td>";
 | 
			
		||||
         echo "   </tr>";
 | 
			
		||||
         $ooe++;
 | 
			
		||||
         $line++;
 | 
			
		||||
@@ -58,7 +70,7 @@ function displayTips($tips)
 | 
			
		||||
    //}
 | 
			
		||||
    echo '<div id="tips"><p><b>Tips:</b></p>';
 | 
			
		||||
    foreach ($tips as $tip) {
 | 
			
		||||
        echo "<li>$tip</li>";
 | 
			
		||||
        echo "<p>$tip</p>";
 | 
			
		||||
        echo "\n";
 | 
			
		||||
    }
 | 
			
		||||
    echo '</div>';
 | 
			
		||||
@@ -84,6 +96,7 @@ function displayMonTable()
 | 
			
		||||
            <td>Plug-in Name</td>
 | 
			
		||||
            <td>Status</td>
 | 
			
		||||
            <td>Node Status Monitoring</td>
 | 
			
		||||
            <td>Action</td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
TOS1;
 | 
			
		||||
@@ -142,7 +155,7 @@ TOS2;
 | 
			
		||||
function displayStatus()
 | 
			
		||||
{
 | 
			
		||||
    //tell the user that the current interface is not done yet...
 | 
			
		||||
    echo "<div><p>This interface is still under development -use accordingly.</p></div>";
 | 
			
		||||
    echo "<div id='devstatus'><p>This interface is still under development -use accordingly.</p></div>";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayOSITree()
 | 
			
		||||
@@ -172,50 +185,216 @@ echo <<<TOS5
 | 
			
		||||
            <td>State</td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
TOS5;
 | 
			
		||||
    //$xml = docmd("webrun", "", array("lscondresp"));
 | 
			
		||||
    //if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
        //echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        //exit;
 | 
			
		||||
    //}
 | 
			
		||||
    $xml = docmd("webrun", "", array("lscondresp"));
 | 
			
		||||
    if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    //get all the condition&response associations for RMC
 | 
			
		||||
echo <<<TOS6
 | 
			
		||||
<tbody>
 | 
			
		||||
<tr class="ListLine0">
 | 
			
		||||
<td>NodeReachability_H</td>
 | 
			
		||||
<td>UpdatexCATNodeStatus</td>
 | 
			
		||||
<td>hv8plus01.ppd.pok.ibm.com</td>
 | 
			
		||||
<td>Not active</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr class="ListLine1">
 | 
			
		||||
<td>NodeReachability</td>
 | 
			
		||||
<td>UpdatexCATNodeStatus</td>
 | 
			
		||||
<td>hv8plus01.ppd.pok.ibm.com</td>
 | 
			
		||||
<td>Not active</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
</div>
 | 
			
		||||
TOS6;
 | 
			
		||||
    foreach ($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
        //get the data from xcatd
 | 
			
		||||
        $association = explode("=", $data);
 | 
			
		||||
 | 
			
		||||
        $ooe = 0;
 | 
			
		||||
        $line = 0;
 | 
			
		||||
        foreach($association as $elem) {
 | 
			
		||||
            $ooe = $ooe%2;
 | 
			
		||||
            //the format should be
 | 
			
		||||
            //"NodeReachability"\t"EmailRootOffShift"\t"hv8plus01.ppd.pok.ibm.com"\t"Active"
 | 
			
		||||
            $record = explode("\"", $elem);
 | 
			
		||||
            $cond = $record[1];
 | 
			
		||||
            $resp = $record[3];
 | 
			
		||||
            $node = $record[5];
 | 
			
		||||
            $state = $record[7];
 | 
			
		||||
            echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
            echo "<td>$cond</td>";
 | 
			
		||||
            echo "<td>$resp</td>";
 | 
			
		||||
            echo "<td>$node</td>";
 | 
			
		||||
            echo "<td>$state</td>";
 | 
			
		||||
            echo "</tr>";
 | 
			
		||||
            $ooe++;
 | 
			
		||||
            $line++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    echo "</tbody></table></div>";
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayCond($noderange)
 | 
			
		||||
function displayCond()
 | 
			
		||||
{
 | 
			
		||||
    //the user selects one node/noderange from the #ositree div
 | 
			
		||||
    echo '<div id="avail_cond">';
 | 
			
		||||
    echo '<b>Available Conditions</b>';
 | 
			
		||||
    
 | 
			
		||||
    echo '</div>';
 | 
			
		||||
echo <<<COND
 | 
			
		||||
<div id="avail_cond">
 | 
			
		||||
<b>Available Conditions</b>
 | 
			
		||||
<table id="tabTable" class="tabTable" cellspacing="1">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr class="colHeaders">
 | 
			
		||||
            <td></td>
 | 
			
		||||
            <td>Conditions</td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
COND;
 | 
			
		||||
    $xml = docmd("webrun", '', array("lscondition"));
 | 
			
		||||
    foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
        //get the data from xcatd
 | 
			
		||||
        $conditions = explode("=", $data);
 | 
			
		||||
    }
 | 
			
		||||
    $ooe = 0;
 | 
			
		||||
    $line = 0;
 | 
			
		||||
    foreach($conditions as $elem) {
 | 
			
		||||
        $ooe = $ooe%2;
 | 
			
		||||
        echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
        echo "<td><input type=\"radio\" name=\"conditions\" value=\"$elem\" /></td>";
 | 
			
		||||
        echo "<td>$elem</td>";
 | 
			
		||||
        echo "</tr>";
 | 
			
		||||
        $ooe++;
 | 
			
		||||
        $line++;
 | 
			
		||||
    }
 | 
			
		||||
    echo "</tbody></table></div>";
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayResp()
 | 
			
		||||
{
 | 
			
		||||
    echo '<div id="avail_resp">';
 | 
			
		||||
    echo '<b>Available Response</b>';
 | 
			
		||||
    echo '</div>';
 | 
			
		||||
echo <<<RESP
 | 
			
		||||
<div id="avail_resp">
 | 
			
		||||
<b>Available Response</b>
 | 
			
		||||
<table id="tabTable" class="tabTable" cellspacing="1">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr class="colHeaders">
 | 
			
		||||
            <td></td>
 | 
			
		||||
            <td>Response</td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
RESP;
 | 
			
		||||
  $xml=docmd("webrun", '', array("lsresponse"));
 | 
			
		||||
  $ooe=0;
 | 
			
		||||
  $line=0;
 | 
			
		||||
  foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
      $responses = explode("=", $data);
 | 
			
		||||
  }
 | 
			
		||||
  foreach($responses as $elem) {
 | 
			
		||||
      $ooe = $ooe%2;
 | 
			
		||||
      echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
      echo "<td><input type='checkbox' name='responses' value='$elem' /></td>";
 | 
			
		||||
      echo "<td>$elem</td>";
 | 
			
		||||
      echo "</tr>";
 | 
			
		||||
      $ooe++;
 | 
			
		||||
      $line++;
 | 
			
		||||
  }
 | 
			
		||||
    echo '</tbody></table></div>';
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayCondResp()
 | 
			
		||||
{
 | 
			
		||||
    echo '<div id="condresp">';
 | 
			
		||||
    displayAssociation();
 | 
			
		||||
    displayCond();
 | 
			
		||||
    displayResp();
 | 
			
		||||
    insertButtons(array('label'=>'Add', id=>'addAssociation', 'onclick'=>'mkCondResp()'));
 | 
			
		||||
    insertButtons(array('label'=>'Cancel', id=>'cancel_op', 'onclick'=>''));
 | 
			
		||||
    echo '</div>';
 | 
			
		||||
    displayStatus();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayMonsetting()
 | 
			
		||||
//TODO: copied from the function displayTable() from display.php, need update
 | 
			
		||||
{
 | 
			
		||||
    echo "<div class='mContent'>";
 | 
			
		||||
    echo "<h1>$tab</h1>\n";
 | 
			
		||||
    insertButtons(array('label' => 'Save','id' => 'saveit'),
 | 
			
		||||
                    array('label' => 'Cancel', 'id' => 'reset')
 | 
			
		||||
            );
 | 
			
		||||
    $xml = docmd('tabdump', '', array("monsetting"));
 | 
			
		||||
    $headers = getTabHeaders($xml);
 | 
			
		||||
    if(!is_array($headers)){ die("<p>Can't find header line in $tab</p>"); }
 | 
			
		||||
    echo "<table id='tabTable' class='tabTable' cellspacing='1'>\n";
 | 
			
		||||
    #echo "<table class='tablesorter' cellspacing='1'>\n";
 | 
			
		||||
    echo "<thead>";
 | 
			
		||||
    echo "<tr class='colHeaders'><td></td>\n"; # extra cell for the red x
 | 
			
		||||
    #echo "<tr><td></td>\n"; # extra cell for the red x
 | 
			
		||||
    foreach($headers as $colHead) {echo "<td>$colHead</td>"; }
 | 
			
		||||
    echo "</tr>\n"; # close header row
 | 
			
		||||
 | 
			
		||||
    echo "</thead><tbody>";
 | 
			
		||||
    $tableWidth = count($headers);
 | 
			
		||||
    $ooe = 0;
 | 
			
		||||
    $item = 0;
 | 
			
		||||
    $line = 0;
 | 
			
		||||
    $editable = array();
 | 
			
		||||
    foreach($xml->children() as $response) foreach($response->children() as $arr){
 | 
			
		||||
            $arr = (string) $arr;
 | 
			
		||||
            if(ereg("^#", $arr)){
 | 
			
		||||
                    $editable[$line++][$item] = $arr;
 | 
			
		||||
                    continue;
 | 
			
		||||
            }
 | 
			
		||||
            $cl = "ListLine$ooe";
 | 
			
		||||
            $values = splitTableFields($arr);
 | 
			
		||||
            # X row
 | 
			
		||||
            echo "<tr class=$cl id=row$line><td class=Xcell><a class=Xlink title='Delete row'><img class=Ximg src=img/red-x2-light.gif></a></td>";
 | 
			
		||||
            foreach($values as $v){
 | 
			
		||||
                    echo "<td class=editme id='$line-$item'>$v</td>";
 | 
			
		||||
                    $editable[$line][$item++] = $v;
 | 
			
		||||
            }
 | 
			
		||||
            echo "</tr>\n";
 | 
			
		||||
            $line++;
 | 
			
		||||
            $item = 0;
 | 
			
		||||
            $ooe = 1 - $ooe;
 | 
			
		||||
    }
 | 
			
		||||
    echo "</tbody></table>\n";
 | 
			
		||||
    $_SESSION["editable-$tab"] = & $editable; # save the array so we can access it in the next call of this file or change.php
 | 
			
		||||
    echo "<p>";
 | 
			
		||||
    insertButtons(array('label' => 'Add Row', 'id' => 'newrow'));
 | 
			
		||||
    echo "</p>\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayRMCRsrc()
 | 
			
		||||
{
 | 
			
		||||
echo <<<TOS0
 | 
			
		||||
<b>Available RMC Resources</b>
 | 
			
		||||
<table id="tabTable" class="tabTable" cellspacing="1">
 | 
			
		||||
<thead>
 | 
			
		||||
    <tr class="colHeaders">
 | 
			
		||||
    <td></td>
 | 
			
		||||
    <td>Class Name</td>
 | 
			
		||||
    </tr>
 | 
			
		||||
</thead>
 | 
			
		||||
<tbody>
 | 
			
		||||
TOS0;
 | 
			
		||||
    $xml = docmd("webrun", "", array("lsrsrc"));
 | 
			
		||||
    if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
        //get all the class name
 | 
			
		||||
        $classes = explode("=", $data);
 | 
			
		||||
    }
 | 
			
		||||
    $ooe = 0;
 | 
			
		||||
    $line = 0;
 | 
			
		||||
    foreach($classes as $class) {
 | 
			
		||||
        $ooe = $ooe%2;
 | 
			
		||||
        echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
        echo "<td><input type='radio' name='classGrp' value='$class' onclick='showRMCAttrib()' /> </td>";
 | 
			
		||||
        echo "<td>$class</td>";
 | 
			
		||||
        echo "</tr>";
 | 
			
		||||
        $ooe++;
 | 
			
		||||
        $line++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    echo "</tbody></table>";
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function displayRMCAttr()
 | 
			
		||||
{
 | 
			
		||||
    echo "<p>Select the RMC Resource, you will see all its available attributes here.</p>";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								xCAT-UI/monitor/makecondresp.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								xCAT-UI/monitor/makecondresp.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * makecondresp.php
 | 
			
		||||
 * run the command "mkcondresp" and return the value
 | 
			
		||||
 */
 | 
			
		||||
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";
 | 
			
		||||
 | 
			
		||||
$cond = $_REQUEST["cond"];
 | 
			
		||||
$resp = $_REQUEST["resp"];
 | 
			
		||||
 | 
			
		||||
$xml=docmd("webrun", '', array("mkcondresp $cond $resp"));
 | 
			
		||||
if(getXmlErrors($xml, $errors)) {
 | 
			
		||||
    echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo "<p>$resp</p>";
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -13,7 +13,14 @@ require_once "$TOPDIR/lib/monitor_display.php";
 | 
			
		||||
 | 
			
		||||
$name = $_REQUEST['name'];
 | 
			
		||||
 | 
			
		||||
echo $name;
 | 
			
		||||
return 0;
 | 
			
		||||
//echo $name;
 | 
			
		||||
 | 
			
		||||
displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php'));
 | 
			
		||||
 | 
			
		||||
displayTips(array(""));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
displayStatus();
 | 
			
		||||
 | 
			
		||||
insertButtons(array('label' => 'Next', 'id'=> 'next', 'onclick'=>''));
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
@@ -12,23 +12,29 @@ require_once "$TOPDIR/lib/display.php";
 | 
			
		||||
require_once "$TOPDIR/js/jsonwrapper.php";
 | 
			
		||||
 | 
			
		||||
//get all the groups
 | 
			
		||||
$xml=docmd("lsdef","",array("-t", "group"));
 | 
			
		||||
//$xml=docmd("lsdef","",array("-t", "group"));
 | 
			
		||||
//if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
//    echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
//    exit;
 | 
			
		||||
//}
 | 
			
		||||
//$groups = array();
 | 
			
		||||
//$jdata = array();
 | 
			
		||||
//foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
    //all the groups are stored into $groups
 | 
			
		||||
//    array_push($groups, $data);
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
$xml = docmd("lsdef","",array("-t", "node", "-w", "nodetype=~osi"));
 | 
			
		||||
if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
    echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
    echo "<p class=Error>", implode(' ', $errors), "</p>";
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
$groups = array();
 | 
			
		||||
$jdata = array();
 | 
			
		||||
foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
    //all the groups are stored into $groups
 | 
			
		||||
    //TODO
 | 
			
		||||
    array_push($groups, $data);
 | 
			
		||||
}
 | 
			
		||||
//foreach($groups as $group) {
 | 
			
		||||
    //$xml = docmd("lsdef","",array("-t", "node", "-w", "nodetype=~osi"))
 | 
			
		||||
//}
 | 
			
		||||
//print_r($groups);
 | 
			
		||||
 | 
			
		||||
$host = system("hostname|cut -f 1 -d \".\"");
 | 
			
		||||
 | 
			
		||||
//print_r($groups);
 | 
			
		||||
//TODO:
 | 
			
		||||
//rebuild the jsTree
 | 
			
		||||
//echo json_encode($jdata);
 | 
			
		||||
echo <<<TOS3
 | 
			
		||||
[
 | 
			
		||||
 
 | 
			
		||||
@@ -12,9 +12,6 @@ require_once "$TOPDIR/lib/display.php";
 | 
			
		||||
require_once "$TOPDIR/lib/monitor_display.php";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<?php
 | 
			
		||||
displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php'));
 | 
			
		||||
 | 
			
		||||
displayTips(array(
 | 
			
		||||
@@ -24,18 +21,9 @@ displayTips(array(
 | 
			
		||||
        "then, click \"Save\" to create condition/response associations."
 | 
			
		||||
        ));
 | 
			
		||||
displayOSITree();
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<div id="condresp">
 | 
			
		||||
    
 | 
			
		||||
<?php
 | 
			
		||||
displayAssociation();
 | 
			
		||||
displayCond("hv8plus06");
 | 
			
		||||
displayResp();
 | 
			
		||||
?>
 | 
			
		||||
</div>
 | 
			
		||||
displayCondResp();
 | 
			
		||||
 | 
			
		||||
<?php
 | 
			
		||||
insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>''));
 | 
			
		||||
insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'loadMainPage("monitor/rmc_resource_define.php")'));
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										53
									
								
								xCAT-UI/monitor/rmc_resource_attr.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								xCAT-UI/monitor/rmc_resource_attr.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * To change this template, choose Tools | Templates
 | 
			
		||||
 * and open the template in the editor.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
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";
 | 
			
		||||
 | 
			
		||||
$class = $_REQUEST['name'];
 | 
			
		||||
 | 
			
		||||
if(!isset($class)) {
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$xml = docmd("webrun", "", array("lsrsrcdef-api -r $class | cut -d':' -f1"));
 | 
			
		||||
if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
    echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
    $attrs = explode("=", $data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$ooe = 0;
 | 
			
		||||
$line = 0;
 | 
			
		||||
echo<<<EOS0
 | 
			
		||||
<b>Available Attributes for $class</b>
 | 
			
		||||
<table id="tabTable" class="tabTable" cellspacing="1">
 | 
			
		||||
<thead>
 | 
			
		||||
    <tr class="colHeaders">
 | 
			
		||||
    <td>Class Name</td>
 | 
			
		||||
    </tr>
 | 
			
		||||
</thead>
 | 
			
		||||
<tbody>
 | 
			
		||||
EOS0;
 | 
			
		||||
 | 
			
		||||
foreach($attrs as $attr) {
 | 
			
		||||
    $ooe = $ooe%2;
 | 
			
		||||
    echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
    echo "<td>$attr</td>";
 | 
			
		||||
    echo "</tr>";
 | 
			
		||||
    $ooe++;
 | 
			
		||||
    $line++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
echo "</tbody></table>";
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										32
									
								
								xCAT-UI/monitor/rmc_resource_define.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								xCAT-UI/monitor/rmc_resource_define.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * define the performance monitoring using RMC
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
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";
 | 
			
		||||
 | 
			
		||||
displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php'));
 | 
			
		||||
 | 
			
		||||
displayTips(array("All the available RMC resources are listed here;",
 | 
			
		||||
    "Edit this table to define the RMC performance monitoring;",
 | 
			
		||||
    "Select the RMC resource, you can get all the available attributes."));
 | 
			
		||||
 | 
			
		||||
displayMonsetting();
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<div id="monsetting_tips">
 | 
			
		||||
    <div id="rmcSrcList"><?php displayRMCRsrc(); ?></div>
 | 
			
		||||
    <div id="rmcScrAttr"><?php displayRMCAttr(); ?></div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<div><?php displayStatus(); ?></div>
 | 
			
		||||
<?php
 | 
			
		||||
insertButtons(array('label'=>'Next', 'id'=>'next', 'onclick'=>'loadMainPage("monitor/monlist.php");'));
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										73
									
								
								xCAT-UI/monitor/setup.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								xCAT-UI/monitor/setup.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * To change this template, choose Tools | Templates
 | 
			
		||||
 * and open the template in the editor.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
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'];
 | 
			
		||||
 | 
			
		||||
//read the "monitoring" table to see whether node status monitoring is enable or not
 | 
			
		||||
$xml = docmd("webrun", "", array("gettab name=$name monitoring.nodestatmon"));
 | 
			
		||||
if(getXmlErrors($xml, $errors)) {
 | 
			
		||||
    echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
foreach($xml->children() as $response) foreach($response->children() as $data)
 | 
			
		||||
{
 | 
			
		||||
    $nodemonstat = $data;
 | 
			
		||||
}
 | 
			
		||||
switch($action) {
 | 
			
		||||
    case "stop":
 | 
			
		||||
        monstop($name, $nmstat);
 | 
			
		||||
        break;
 | 
			
		||||
    case "restart":
 | 
			
		||||
        monrestart($name, $nmstat);
 | 
			
		||||
        break;
 | 
			
		||||
    case "start":
 | 
			
		||||
        monstart($name, $nmstat);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        break;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function monstop($plugin, $nmstat)
 | 
			
		||||
{
 | 
			
		||||
    $xml = docmd("monstop", "", array("$plugin","-r"));
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function monrestart($plugin, $nmstat)
 | 
			
		||||
{
 | 
			
		||||
    $xml = docmd("monstop", "", array("$plugin", "-r"));
 | 
			
		||||
    if(getXmlErrors($xml, $errors)) {
 | 
			
		||||
        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    $xml = docmd("moncfg", "", array("$plugin", "-r"));
 | 
			
		||||
    if(getXmlErrors($xml, $errors)) {
 | 
			
		||||
        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $xml = docmd("monstart", "", array("$plugin", "-r"));
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function monstart($plugin, $nmstat)
 | 
			
		||||
{
 | 
			
		||||
    //before starting the $plugin,
 | 
			
		||||
    //we have to make sure that the plugin is added in the "monitoring" table
 | 
			
		||||
    $xml = docmd("monstart", "", array("$plugin", "-r"));
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -42,5 +42,5 @@ display_stat_mon_table(array("$name"=>
 | 
			
		||||
 | 
			
		||||
displayStatus();
 | 
			
		||||
 | 
			
		||||
insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'goto_next()'));
 | 
			
		||||
insertButtons(array('label'=>'Next', id=>'next', 'onclick'=>'loadMainPage("monitor/monlist.php")'));
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										59
									
								
								xCAT-UI/monitor/updateCondRespTable.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								xCAT-UI/monitor/updateCondRespTable.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * update the condition&response association
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
if(!isset($TOPDIR)) { $TOPDIR="/opt/xcat/ui";}
 | 
			
		||||
 | 
			
		||||
require_once "$TOPDIR/lib/functions.php";
 | 
			
		||||
require_once "$TOPDIR/lib/security.php";
 | 
			
		||||
require_once "$TOPDIR/lib/display.php";
 | 
			
		||||
require_once "$TOPDIR/js/jsonwrapper.php";
 | 
			
		||||
 | 
			
		||||
echo <<<TOS5
 | 
			
		||||
<b>Available Condition/Response Associations</b>
 | 
			
		||||
<table id="tabTable" class="tabTable" cellspacing="1">
 | 
			
		||||
    <thead>
 | 
			
		||||
        <tr class="colHeaders">
 | 
			
		||||
            <td>Condition</td>
 | 
			
		||||
            <td>Response</td>
 | 
			
		||||
            <td>Node</td>
 | 
			
		||||
            <td>State</td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
TOS5;
 | 
			
		||||
    $xml = docmd("webrun", "", array("lscondresp"));
 | 
			
		||||
    if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
        echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
        exit;
 | 
			
		||||
    }
 | 
			
		||||
    //get all the condition&response associations for RMC
 | 
			
		||||
    foreach ($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
        //get the data from xcatd
 | 
			
		||||
        $association = explode("=", $data);
 | 
			
		||||
 | 
			
		||||
        $ooe = 0;
 | 
			
		||||
        $line = 0;
 | 
			
		||||
        foreach($association as $elem) {
 | 
			
		||||
            $ooe = $ooe%2;
 | 
			
		||||
            //the format should be
 | 
			
		||||
            //"NodeReachability"\t"EmailRootOffShift"\t"hv8plus01.ppd.pok.ibm.com"\t"Active"
 | 
			
		||||
            $record = explode("\"", $elem);
 | 
			
		||||
            $cond = $record[1];
 | 
			
		||||
            $resp = $record[3];
 | 
			
		||||
            $node = $record[5];
 | 
			
		||||
            $state = $record[7];
 | 
			
		||||
            echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
            echo "<td>$cond</td>";
 | 
			
		||||
            echo "<td>$resp</td>";
 | 
			
		||||
            echo "<td>$node</td>";
 | 
			
		||||
            echo "<td>$state</td>";
 | 
			
		||||
            echo "</tr>";
 | 
			
		||||
            $ooe++;
 | 
			
		||||
            $line++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    echo "</tbody></table>";
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										48
									
								
								xCAT-UI/monitor/updateMonList.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								xCAT-UI/monitor/updateMonList.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* 
 | 
			
		||||
 * To change this template, choose Tools | Templates
 | 
			
		||||
 * and open the template in the editor.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
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";
 | 
			
		||||
 | 
			
		||||
$xml = docmd("monls"," ", array('-a'));
 | 
			
		||||
 if(getXmlErrors($xml,$errors)) {
 | 
			
		||||
     echo "<p class=Error>",implode(' ', $errors), "</p>";
 | 
			
		||||
     exit;
 | 
			
		||||
 }
 | 
			
		||||
 #then, parse the xml data
 | 
			
		||||
 $ooe = 0;
 | 
			
		||||
 $line = 0;
 | 
			
		||||
 foreach($xml->children() as $response) foreach($response->children() as $data) {
 | 
			
		||||
     list($name, $stat, $nodemonstatus) = preg_split("/\s+/", $data);
 | 
			
		||||
     $ooe = $ooe%2;
 | 
			
		||||
     echo "<tr class='ListLine$ooe' id='row$line'>";
 | 
			
		||||
     echo "<td><input type='radio' name='plugins' value='$name' /></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 "<td>";
 | 
			
		||||
     $name_str = "\"$name\"";
 | 
			
		||||
     if($stat == "monitored") {
 | 
			
		||||
         $act_str = "\"stop\"";
 | 
			
		||||
         insertButtons(array('label'=>'Stop', 'id'=>'stop', 'onclick'=>"monsetupAction($name_str, $act_str)"));
 | 
			
		||||
         $act_str = "\"restart\"";
 | 
			
		||||
         insertButtons(array('label'=>'Restart', 'id'=>'restart', 'onclick'=>"monsetupAction($name_str, $act_str)"));
 | 
			
		||||
     }else {
 | 
			
		||||
         $act_str = "\"start\"";
 | 
			
		||||
         insertButtons(array('label' => 'Start', 'id'=>'start', 'onclick' => "monsetupAction($name_str, $act_str)"));
 | 
			
		||||
     }
 | 
			
		||||
     echo "</td>";
 | 
			
		||||
     echo "   </tr>";
 | 
			
		||||
     $ooe++;
 | 
			
		||||
     $line++;
 | 
			
		||||
     //echo "<tr><td><input type='checkbox' />$name</td><td>$stat</td><td><a onclick='LoadMainPage("main.php")'>$name</a></td></tr>";
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user