diff --git a/xCAT-UI/js/xcat.js b/xCAT-UI/js/xcat.js index 35f89ad1b..5b3e611ad 100644 --- a/xCAT-UI/js/xcat.js +++ b/xCAT-UI/js/xcat.js @@ -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
is show available options to the user + //at first, hide the
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("

Please select one or more attributes from the table

"); + } +} + function show_monshow_graph() { //used for the "view by graph" button in the web page "rmc_monshow.php" if($(":input[@checked]").size() != 0) { diff --git a/xCAT-UI/lib/monitor_display.php b/xCAT-UI/lib/monitor_display.php index e8e665e96..355e82192 100644 --- a/xCAT-UI/lib/monitor_display.php +++ b/xCAT-UI/lib/monitor_display.php @@ -307,57 +307,6 @@ function displayCondResp() displayStatus(); } -function displayMonsetting() -//TODO: copied from the function displayTable() from display.php, need update -{ - echo "
"; - echo "

$tab

\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("

Can't find header line in $tab

"); } - echo "\n"; - #echo "
\n"; - echo ""; - echo "\n"; # extra cell for the red x - #echo "\n"; # extra cell for the red x - foreach($headers as $colHead) {echo ""; } - echo "\n"; # close header row - - echo ""; - $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 ""; - foreach($values as $v){ - echo ""; - $editable[$line][$item++] = $v; - } - echo "\n"; - $line++; - $item = 0; - $ooe = 1 - $ooe; - } - echo "
$colHead
$v
\n"; - $_SESSION["editable-$tab"] = & $editable; # save the array so we can access it in the next call of this file or change.php - echo "

"; - insertButtons(array('label' => 'Add Row', 'id' => 'newrow')); - echo "

\n"; -} - function displayRMCRsrc() { echo <<"; } -function displayRMCMonshowAttr($attr) { +function displayRMCMonshowAttr($attr, $nr) { //TODO: should add one argument to support the noderange argument echo "
"; echo ""; @@ -454,9 +403,17 @@ function displayRMCMonshowAttr($attr) { echo ""; echo ""; - //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 ""; - echo ""; - echo ""; - echo ""; + $tmp = array_pop($arr); + if($tmp == '-') { + $val = array_pop($arr); + $time = implode(" ", $arr); + echo ""; + echo ""; + echo ""; + echo ""; + } } - - echo ""; echo "
$time$val
$time$val
"; echo "
"; } -function displayRMCMonshowGraph($value) { +function displayRMCMonshowGraph($value, $nr) { //display the RMC Performance Data echo << @@ -555,12 +513,6 @@ function displayOptionsForPlugin($name) //there should be many choices for the user to view the clusters' status echo << - - - Monitor Items - Display Formats - - TOS1; if($name == "rmcmon") { @@ -574,8 +526,7 @@ TOS1; echo ""; echo "RMC Resource Logs"; echo ""; - 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 ""; echo ""; } diff --git a/xCAT-UI/monitor/flot_get_data.php b/xCAT-UI/monitor/flot_get_data.php index f3ecb848a..48a4df776 100644 --- a/xCAT-UI/monitor/flot_get_data.php +++ b/xCAT-UI/monitor/flot_get_data.php @@ -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 { diff --git a/xCAT-UI/monitor/rmc_monshow.php b/xCAT-UI/monitor/rmc_monshow.php index 1142e747d..2b1bce90e 100644 --- a/xCAT-UI/monitor/rmc_monshow.php +++ b/xCAT-UI/monitor/rmc_monshow.php @@ -25,6 +25,7 @@ insertDiv("rmc_tree"); "; +echo "

Select the monitor range from the tree on the left

"; echo "
"; //if the user clicks the "View by Text" button, the div named "monshow_data" will show // the text data from the "monshow" command; diff --git a/xCAT-UI/monitor/rmc_monshow_attr_source.php b/xCAT-UI/monitor/rmc_monshow_attr_source.php index a800c29c8..3c4eb90f0 100644 --- a/xCAT-UI/monitor/rmc_monshow_attr_source.php +++ b/xCAT-UI/monitor/rmc_monshow_attr_source.php @@ -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 "Currently, it only supports one single node. Please select one single node under the LPAR tree."; + } } -function show_monshow_options() +function show_monshow_options($id) { -echo <<Choose the attributes to display -TOS0; -show_rmc_monsetting(); -echo "
"; -//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 "
"; -echo "
"; + echo "Choose the attributes to display"; + show_rmc_monsetting(); + echo "
"; + //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 "
"; + echo "
"; } function show_rmc_monsetting() diff --git a/xCAT-UI/monitor/rmc_monshow_data_source.php b/xCAT-UI/monitor/rmc_monshow_data_source.php index d4e081793..d2c74e9f4 100644 --- a/xCAT-UI/monitor/rmc_monshow_data_source.php +++ b/xCAT-UI/monitor/rmc_monshow_data_source.php @@ -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); } diff --git a/xCAT-UI/monitor/rmc_resource_define.php b/xCAT-UI/monitor/rmc_resource_define.php index c14a5488b..29341b021 100644 --- a/xCAT-UI/monitor/rmc_resource_define.php +++ b/xCAT-UI/monitor/rmc_resource_define.php @@ -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 "
"; +echo "
"; +echo<< +$('#testme').load('config.php?t=monsetting'); + +TOS0; echo '
'; echo '
'; displayRMCRsrc(); diff --git a/xCAT-UI/monitor/rmc_source.php b/xCAT-UI/monitor/rmc_source.php index b9ea7fff5..8db54446f 100644 --- a/xCAT-UI/monitor/rmc_source.php +++ b/xCAT-UI/monitor/rmc_source.php @@ -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); ?> diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php index 63bba8b4a..5509d2683 100644 --- a/xCAT-UI/monitor/setup.php +++ b/xCAT-UI/monitor/setup.php @@ -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 "

",implode(' ', $errors), "

"; - 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 "

",implode(' ', $errors), "

"; +// 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 "

",implode(' ', $errors), "

"; + 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 "

",implode(' ', $errors), "

"; + exit; + } + } //we have to make sure that the plugin is added in the "monitoring" table $xml = docmd("monstart", "", array("$plugin", "-r")); return 0;