some code change for "monitoring interface";

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4158 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2009-09-17 14:54:43 +00:00
parent 57ceb3892f
commit f4057ce24d
9 changed files with 176 additions and 159 deletions

View File

@ -354,7 +354,7 @@ function init_ositree(){
//
//}
//update the osi tree used in
//update the osi tree
function init_rmc_ositree() {
nrtree = new tree_component(); //-tree begin
nrtree.init($("#rmc_tree"),{
@ -362,14 +362,15 @@ function init_rmc_ositree() {
ui: { animation: 250 },
callback: {
onchange: function(n) {
$("#monshow_tip_1").hide();
if(n.id) {
if($(n).parent().parent().attr("id") == ",lpar") {
//parse the id, then display the "monshow" data for selected noderange
$.get("monitor/rmc_monshow_attr_source.php", {id: n.id}, function(data) {
//display the "monshow" result
$("#monshow_opt").html(data);
});
}
//if($(n).parent().parent().attr("id") == ",lpar") {
//parse the id, then display the "monshow" data for selected noderange
$.get("monitor/rmc_monshow_attr_source.php", {id: n.id}, function(data) {
//display the "monshow" result
$("#monshow_opt").html(data);
});
//}
}
}
},
@ -481,6 +482,10 @@ function showPluginOptions()
//for monlist.php, when the user clicks the radiobox, the available options for the plugin will display
$("input[@name=plugins]").click(function() {
//when one radiobox is selected, the #options <div> is show available options to the user
//at first, hide the <div> named with "#plugin_desc"
if($("#plugin_desc").css("display") == "block") {
$("#plugin_desc").hide("slow");
}
var plugin = $(this).attr('value');
$.get("monitor/options.php", {name:plugin},function(data) {
$("#options").html(data);
@ -491,6 +496,9 @@ function showPluginOptions()
function showPluginDescription()
{
$(".description").click(function(){
if($("#plugin_desc").css("display") == "none") {
$("#plugin_desc").show();
}
$.get("monitor/plugin_desc.php", {name: $(this).text()}, function(data){
$("#plugin_desc").html(data);
})
@ -508,6 +516,26 @@ function monsetupAction(plugin, action_val)
});
}
function show_monshow_data(type,range)
{
//type = "text" or "graph"
//range = "cluster", "summary" and nodename
//used in the web page "rmc_monshow.php"
if($(":input[@checked]").size() != 0) {
$("#monshow_data").empty();
$("#monshow_opt").hide("slow");
$("#back_btn").show("slow");
$(":input[@checked]").each(function(i) {
//generate text/graphics for all the attributes in "checked" status
$.get("monitor/rmc_monshow_data_source.php", {mode: type, value: $(this).attr("value"), nr: range}, function(data) {
$("#monshow_data").append(data);
});
});
}else {
$("#monshow_data").html("<p><b>Please select one or more attributes from the table</b></p>");
}
}
function show_monshow_graph() {
//used for the "view by graph" button in the web page "rmc_monshow.php"
if($(":input[@checked]").size() != 0) {

View File

@ -307,57 +307,6 @@ function displayCondResp()
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
@ -442,7 +391,7 @@ TOS8;
echo "</div>";
}
function displayRMCMonshowAttr($attr) {
function displayRMCMonshowAttr($attr, $nr) {
//TODO: should add one argument to support the noderange argument
echo "<div>";
echo "<table class='tablesorter' cellspacing='1'>";
@ -454,9 +403,17 @@ function displayRMCMonshowAttr($attr) {
echo "</thead>";
echo "<tbody>";
//get all the data by the command "monshow"
$xml = docmd("monshow", "", array("rmcmon", "-s", "-t", "60", "-a", "$attr"));
//the error handling is skipped
if($nr == "cluster") {
//get all the data by the command "monshow"
$xml = docmd("monshow", "", array("rmcmon", "-t", "60", "-a", "$attr"));
//the error handling is skipped
}elseif($nr == "summary") {
$xml = docmd("monshow", "", array("rmcmon", "-s", "-t", "60", "-a", "$attr"));
}else {
$xml = docmd("monshow", "", array("rmcmon", "$nr", "-t", "60", "-a", "$attr"));
}
//the formats of the data are different based on $nr
//print_r($xml);
$index = 0;
foreach($xml->children() as $response) foreach($response->children() as $data) {
//handle the data here
@ -467,21 +424,22 @@ function displayRMCMonshowAttr($attr) {
//then, parse "date" & "value"
$arr = preg_split("/\s+/", $data);
array_pop($arr);
$val = array_pop($arr);
$time = implode(" ", $arr);
echo "<tr>";
echo "<td>$time</td>";
echo "<td>$val</td>";
echo "</tr>";
$tmp = array_pop($arr);
if($tmp == '-') {
$val = array_pop($arr);
$time = implode(" ", $arr);
echo "<tr>";
echo "<td>$time</td>";
echo "<td>$val</td>";
echo "</tr>";
}
}
echo "</tbody>";
echo "</table>";
echo "</div>";
}
function displayRMCMonshowGraph($value) {
function displayRMCMonshowGraph($value, $nr) {
//display the RMC Performance Data
echo <<<TOS11
<div>
@ -555,12 +513,6 @@ function displayOptionsForPlugin($name)
//there should be many choices for the user to view the clusters' status
echo <<<TOS1
<table id="view_tab" class="tabTable" cellspacing="1">
<thead>
<tr class='colHeaders'>
<td>Monitor Items</td>
<td>Display Formats</td>
</tr>
</thead>
<tbody>
TOS1;
if($name == "rmcmon") {
@ -574,8 +526,7 @@ TOS1;
echo "<tr class='ListLine1' id='row1'>";
echo "<td>RMC Resource Logs</td>";
echo "<td>";
insertButtons(array('label'=>'View in Text', 'id'=>'rmc_resrc_text', 'onclick'=>'loadMainPage("monitor/rmc_monshow.php")'));
insertButtons(array('label'=>'View in Graphics', 'id'=>'rmc_resrc_graph', 'onclick'=>''));
insertButtons(array('label'=>'View By text/graphics', 'id'=>'rmc_resrc_text', 'onclick'=>'loadMainPage("monitor/rmc_monshow.php")'));
echo "</td>";
echo "</tr>";
}

View File

@ -46,7 +46,7 @@ foreach ($xml->children() as $response) foreach($response->children() as $data)
$val = array_pop($arr);
$time = implode(" ", $arr);
$timestamp = strtotime($time);
$timestamp .=1000;
$timestamp .="000";
if($index++==2) {
echo "[$timestamp,$val]";
} else {

View File

@ -25,6 +25,7 @@ insertDiv("rmc_tree");
<?php
echo "<div id='rmc_monshow'>";
echo "<div id='monshow_tip_1'><p><b>Select the monitor range from the tree on the left</b></p></div>";
echo "<div id='monshow_opt'></div>";
//if the user clicks the "View by Text" button, the div named "monshow_data" will show
// the text data from the "monshow" command;

View File

@ -6,38 +6,47 @@ require_once "$TOPDIR/lib/functions.php";
require_once "$TOPDIR/lib/display.php";
require_once "$TOPDIR/lib/monitor_display.php";
//$id is the sel
//$id is the selected noderange to display
$id = $_REQUEST['id'];
$id = preg_replace('/^,/', '', $id);
//TODO: now it only supports one single node
if($id == "cluster") {
//handle the condition: with option -s and the noderange is MN
show_monshow_options($id);
} elseif($id == "summary") {
//handle the "-s" option
//TODO: the condition with option -s and the noderange is SN(s) is not considered
show_monshow_options($id);
//check whether the node is "osi" type or not
//using the command = webrun "lsdef -t node $id -i nodetype"
$xml = docmd("webrun", "", array("lsdef $id -i nodetype"));
//no error message will be returned
} else {
//check whether the node is "osi" type or not
//using the command = webrun "lsdef -t node $id -i nodetype"
foreach($xml->children() as $response) foreach($response->children() as $data) {
$xml = docmd("webrun", "", array("lsdef $id -i nodetype"));
//no error message will be returned
}
if(false !== strpos($data, "lpar")) {
//display the options for the "monshow" command
foreach($xml->children() as $response) foreach($response->children() as $data) {
show_monshow_options();
}
if(false !== strpos($data, "lpar")) {
//display the options for the "monshow" command
show_monshow_options($id);
} else {
echo "<b>Currently, it only supports one single node. Please select one single node under the LPAR tree.</b>";
}
}
function show_monshow_options()
function show_monshow_options($id)
{
echo <<<TOS0
<b>Choose the attributes to display</b>
TOS0;
show_rmc_monsetting();
echo "<div>";
//click the "OK" button, "monshow" data for the selected attributes will display
insertButtons(array('label'=>'View by Text', 'id'=>'monshow_text_btn', 'onclick'=>'show_monshow_text()'));
insertButtons(array('label'=>'View by Graphics', 'id'=>'monshow_graph_btn', 'onclick'=>'show_monshow_graph()'));
echo "</div>";
echo "</div>";
echo "<b>Choose the attributes to display</b>";
show_rmc_monsetting();
echo "<div>";
//click the "OK" button, "monshow" data for the selected attributes will display
insertButtons(array('label'=>'Text View', 'id'=>'monshow_text_btn', 'onclick'=>"show_monshow_data(\"text\",\"$id\")"));
insertButtons(array('label'=>'Graph View', 'id'=>'monshow_graph_btn', 'onclick'=>"show_monshow_data(\"graph\",\"$id\")"));
echo "</div>";
echo "</div>";
}
function show_rmc_monsetting()

View File

@ -9,13 +9,15 @@ require_once "$TOPDIR/lib/monitor_display.php";
$mode = $_REQUEST['mode'];
$value = $_REQUEST['value'];
$nr = $_REQUEST['nr'];
//nr = "cluster" or "summary" or node name
if($mode == "text") {
displayRMCMonshowAttr($value);
displayRMCMonshowAttr($value, $nr);
} elseif($mode == "graph") {
//display the pictures generated by "rrdtool";
//in the feture, the pictures will be generated by jQuery plug-ins;
displayRMCMonshowGraph($value);
displayRMCMonshowGraph($value, $nr);
}

View File

@ -16,9 +16,14 @@ 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();
//displayMonsetting();
echo "<div id='testme'>";
echo "</div>";
echo<<<TOS0
<script type="text/javascript">
$('#testme').load('config.php?t=monsetting');
</script>
TOS0;
echo '<div id="monsetting_tips">';
echo '<div id="rmcSrcList">';
displayRMCRsrc();

View File

@ -12,42 +12,41 @@ require_once "$TOPDIR/js/jsonwrapper.php";
$id = $_GET['id'];
}
if ($id == "0") {
$id = '/.*';
echo '[{"data":"cluster","attributes":{"id":",cluster","rel":"node"}},{"data":"summary","attributes":{"id":",summary","rel":"node"}},{"data":"lpar","attributes":{"id":",lpar","rel":"group"},"state":"closed"}]';
} else {
$id=preg_replace('/^,/','',$id);
}
$rvals=docmd('extnoderange',$id,array('subgroups'));
$parents=array();
$root=1;
if ($id == '/.*') {
$id=',';
} else {
$parents=split("@",$id);
$id=",$id@";
$root=0;
}
//unset($rvals->xcatresponse->serverdone[0]);
$numsubgroups=count($rvals->xcatresponse->intersectinggroups);
$numnodes=count($rvals->xcatresponse->node);
$jdata=array();
if ($numnodes >= $numsubgroups) { #If there are few enough subgroups to be helpful filters, add them in
foreach ($rvals->xcatresponse->intersectinggroups as $group) {
if (! in_array("$group",$parents)) {
$jdata[]= array("data"=>"$group",
"attributes"=>array("id"=>"$id$group",
"rel"=>'group'),
"state"=>'closed');
}
$rvals=docmd('extnoderange',$id,array('subgroups'));
$parents=array();
$root=1;
if ($id == '/.*') {
$id=',';
} else {
$parents=split("@",$id);
$id=",$id@";
$root=0;
}
} #If there were more groups than nodes, leave the signal to noise ratio down
if ($root==0) {
foreach ($rvals->xcatresponse->node as $node) {
$jdata[] = array("data"=>"$node",
"attributes"=>array("id"=>",$node",
"rel"=>'node'));
//unset($rvals->xcatresponse->serverdone[0]);
$numsubgroups=count($rvals->xcatresponse->intersectinggroups);
$numnodes=count($rvals->xcatresponse->node);
$jdata=array();
if ($numnodes >= $numsubgroups) { #If there are few enough subgroups to be helpful filters, add them in
foreach ($rvals->xcatresponse->intersectinggroups as $group) {
if (! in_array("$group",$parents)) {
$jdata[]= array("data"=>"$group",
"attributes"=>array("id"=>"$id$group",
"rel"=>'group'),
"state"=>'closed');
}
}
} #If there were more groups than nodes, leave the signal to noise ratio down
if ($root==0) {
foreach ($rvals->xcatresponse->node as $node) {
$jdata[] = array("data"=>"$node",
"attributes"=>array("id"=>",$node",
"rel"=>'node'));
}
}
echo json_encode($jdata);
}
}
# header('Content-type: text/html');
echo json_encode($jdata);
?>

View File

@ -16,37 +16,37 @@ $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;
}
//$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);
monstop($name);
break;
case "restart":
monrestart($name, $nmstat);
monrestart($name);
break;
case "start":
monstart($name, $nmstat);
monstart($name);
break;
default:
break;
}
function monstop($plugin, $nmstat)
function monstop($plugin)
{
$xml = docmd("monstop", "", array("$plugin","-r"));
return 0;
}
function monrestart($plugin, $nmstat)
function monrestart($plugin)
{
$xml = docmd("monstop", "", array("$plugin", "-r"));
if(getXmlErrors($xml, $errors)) {
@ -63,9 +63,31 @@ function monrestart($plugin, $nmstat)
return 0;
}
function monstart($plugin, $nmstat)
function monstart($plugin)
{
//TODO:before starting the $plugin,
//Before running "monstart", the command "monls" is used to check
$xml = docmd("monls","", NULL);
if(getXmlErrors($xml, $errors)) {
echo "<p class=Error>",implode(' ', $errors), "</p>";
exit;
}
$has_plugin = false;
if(count($xml->children()) != 0) {
foreach($xml->children() as $response) foreach($response->children() as $data) {
$arr = preg_split("/\s+/", $data);
if($arr[0] == $plugin) {
$has_plugin = true;
}
}
}
if($has_plugin == false) {
//if $has_plugin == false, that means the plugin is not added into the monitoring table
$xml = docmd("monadd",'', array("$plugin"));
if(getXmlErrors($xml, $errors)) {
echo "<p class=Error>",implode(' ', $errors), "</p>";
exit;
}
}
//we have to make sure that the plugin is added in the "monitoring" table
$xml = docmd("monstart", "", array("$plugin", "-r"));
return 0;