diff --git a/xCAT-UI/js/monitor/rmcmon.js b/xCAT-UI/js/monitor/rmcmon.js index d6e83237a..ed869b238 100644 --- a/xCAT-UI/js/monitor/rmcmon.js +++ b/xCAT-UI/js/monitor/rmcmon.js @@ -2,6 +2,7 @@ var globalErrNodes; var globalNodesDetail; var globalAllNodesNum = 0; var globalFinishNodesNum = 0; +var globalSelectedAttributes = ''; function loadRmcMon(){ //find the rmcmon tab @@ -95,6 +96,12 @@ function loadRmcMonConfigure(){ }); }); + //add the attributes button + var attrButton = createButton('Attribute Select'); + rmcmonCfgDiv.append(attrButton); + attrButton.bind('click',function(){ + showConfigureDia(); + }); //add the cancel button var cancelButton = createButton('Cancel'); rmcmonCfgDiv.append(cancelButton); @@ -193,9 +200,17 @@ function rmcWorkingCheck(){ } function loadRmcMonShow(){ - $('#rmcMonStatus').empty().append("Getting monitoring Data."); + $('#rmcMonStatus').empty().append("Getting monitoring Data(This step may take a long time)."); $('#rmcMonStatus').append(createLoader()); + //init the selected Attributes string + if ($.cookie('rmcmonattr')){ + globalSelectedAttributes = $.cookie('rmcmonattr'); + } + else{ + globalSelectedAttributes = 'PctTotalTimeIdle,PctTotalTimeWait,PctTotalTimeUser,PctTotalTimeKernel,PctRealMemFree'; + } + //load the rmc status summary $.ajax({ url : 'lib/cmd.php', @@ -203,7 +218,7 @@ function loadRmcMonShow(){ data : { cmd : 'webrun', tgt : '', - args : 'rmcshow;summary', + args : 'rmcshow;summary;' + globalSelectedAttributes, msg : '' }, @@ -219,7 +234,7 @@ function loadRmcMonShow(){ data : { cmd : 'webrun', tgt : '', - args : 'rmcshow;lpar', + args : 'rmcshow;lpar;' + globalSelectedAttributes, msg : '' }, @@ -298,7 +313,7 @@ function parseRmcData(returnData){ data : { cmd : 'webrun', tgt : '', - args : 'rmcshow;' + nodeName, + args : 'rmcshow;' + nodeName + ';' + globalSelectedAttributes, msg : nodeName }, @@ -517,4 +532,84 @@ function sortName(x, y){ else{ return -1; } +} + +function showConfigureDia(){ + var diaDiv = $('
'); + var tempArray = globalSelectedAttributes.split(','); + var selectedAttrHash = new Object(); + var wholeAttrArray = new Array('PctTotalTimeIdle','PctTotalTimeWait','PctTotalTimeUser','PctTotalTimeKernel','PctRealMemFree'); + + //init the selectedAttrHash + for (var i in tempArray){ + selectedAttrHash[tempArray[i]] = 1; + } + var attrTable = $('
'); + for (var i in wholeAttrArray){ + var name = wholeAttrArray[i]; + var tempString = ''; + if(selectedAttrHash[name]){ + tempString += ''; + } + else{ + tempString += ''; + } + + tempString += '' + name + ''; + attrTable.append(tempString); + } + + var selectAllButton = createButton('Select All'); + selectAllButton.bind('click', function(){ + $('#rmcAttrTable input[type=checkbox]').attr('checked', true); + }); + diaDiv.append(selectAllButton); + + var unselectAllButton = createButton('Unselect All'); + unselectAllButton.bind('click', function(){ + $('#rmcAttrTable input[type=checkbox]').attr('checked', false); + }); + diaDiv.append(unselectAllButton); + + diaDiv.append(attrTable); + + diaDiv.dialog({ + modal: true, + width: 400, + close: function(event, ui){ + $(this).remove(); + }, + buttons: { + cancel : function(){ + $(this).dialog('close'); + }, + ok : function(){ + //collect all attibutes' name + var str = ''; + $('#rmcAttrTable input:checked').each(function(){ + if('' == str){ + str += $(this).attr('name'); + } + else{ + str += ',' + $(this).attr('name'); + } + }); + + //if no attribute is selected, alert the information. + if ('' == str){ + alert('Please select one attribute at lease!'); + return; + } + + //new selected attributes is different from the old, update the cookie and reload this tab + if ($.cookie('rmcmonattr') != str){ + $.cookie('rmcmonattr', str, {path : '/xcat', expires : 10}); + //todo reload the tab + $('#rmcmon').empty(); + loadRmcMon(); + } + $(this).dialog('close'); + } + } + }); } \ No newline at end of file diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index ab00036d2..74b5f2d04 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -705,6 +705,7 @@ sub web_rmcmonStart { sub web_rmcmonShow() { my ( $request, $callback, $sub_req ) = @_; my $nodeRange = $request->{arg}->[1]; + my $attr = $request->{arg}->[2]; my @nodes; my $retInfo; my $retHash = {}; @@ -718,7 +719,7 @@ sub web_rmcmonShow() { #like this PctTotalTimeIdle=>"10.0000, 20.0000, 12.0000, 30.0000" if ( 'summary' eq $nodeRange ) { $output = - xCAT::Utils->runcmd( "monshow rmcmon -s -t 10 -a PctTotalTimeIdle,PctTotalTimeWait,PctTotalTimeUser,PctTotalTimeKernel,PctRealMemFree", -1, 1 ); + xCAT::Utils->runcmd( "monshow rmcmon -s -t 10 -a " . $attr, -1, 1 ); foreach $temp (@$output) { #the attribute name @@ -819,7 +820,7 @@ sub web_rmcmonShow() { my $attrName = ""; my @attrValue = (); $output = - xCAT::Utils->runcmd( "monshow rmcmon $nodeRange -t 60 -a PctTotalTimeIdle,PctTotalTimeWait,PctTotalTimeUser,PctTotalTimeKernel,PctRealMemFree", -1, 1 ); + xCAT::Utils->runcmd( "monshow rmcmon $nodeRange -t 60 -a " . $attr, -1, 1 ); foreach (@$output) { $temp = $_; if ( $temp =~ /\t/ ) {