From 6da79b8af8993c675b0c60895ae3718366516373 Mon Sep 17 00:00:00 2001 From: phamt Date: Mon, 12 Sep 2011 16:10:53 +0000 Subject: [PATCH] Updated datatable to have action action. Cleaned up code. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10497 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/gangliamon.js | 280 ++++++++-------- xCAT-UI/js/monitor/monitor.js | 10 +- xCAT-UI/js/monitor/rmcmon.js | 526 +++++++++++++++---------------- xCAT-UI/js/monitor/xcatmon.js | 344 ++++++++++---------- 4 files changed, 550 insertions(+), 610 deletions(-) diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js index 173c26912..f1c5dc520 100644 --- a/xCAT-UI/js/monitor/gangliamon.js +++ b/xCAT-UI/js/monitor/gangliamon.js @@ -22,10 +22,10 @@ var gangliaTimer; */ function loadGangliaMon() { // Get Ganglia tab - $('#gangliamon').append(createInfoBar('Checking RPMs.')); + $('#gangliamon').append(createInfoBar('Checking RPMs')); //should get the groups first - if (!$.cookie('groups')){ + if (!$.cookie('groups')) { $.ajax( { url : 'lib/cmd.php', dataType : 'json', @@ -62,12 +62,13 @@ function loadGangliaMon() { function checkGangliaRPMs(data) { var gangliaTab = $('#gangliamon'); gangliaTab.empty(); + // Get the list of Ganglia RPMs installed var status = data.rsp.split(/\n/); var gangliaRPMs = [ "rrdtool", "ganglia-gmetad", "ganglia-gmond"]; var warningMsg = 'Before continuing, please install the following packages: '; var missingRPMs = false; - for ( var i in status) { + for (var i in status) { if (status[i].indexOf("not installed") > -1) { warningMsg += gangliaRPMs[i] + ' '; missingRPMs = true; @@ -82,8 +83,9 @@ function checkGangliaRPMs(data) { warningBar.css('margin-bottom', '10px'); warningBar.prependTo(gangliaTab); } else { - gangliaTab.append(createInfoBar('Checking Running status.')); - // Check if ganglia is running on the xCAT MN + gangliaTab.append(createInfoBar('Checking running status')); + + // Check if ganglia is running on the xCAT MN $.ajax( { url : 'lib/cmd.php', dataType : 'json', @@ -155,7 +157,7 @@ function checkGangliaRunning(data){ } groupsSelectStr = ''; @@ -183,11 +185,11 @@ function checkGangliaRunning(data){ gangliaTab.append(showStr); //get summary data and draw on the page - $('#gangliaGridSummary').append('Getting Grid summary Data.'); + $('#gangliaGridSummary').append('Getting grid summary data '); sendGridSummaryAjax(); //get nodes current status and draw on the page - $('#gangliaNodes').append('Getting ' + $('#gangliagroup').val() + ' nodes Status.'); + $('#gangliaNodes').append('Getting ' + $('#gangliagroup').val() + ' nodes status '); sendNodeCurrentAjax(); //start the timer to update page per minute. @@ -220,14 +222,12 @@ function checkGangliaRunning(data){ } /** - * send ajax request to get grid summary information - * - * @param - * + * Send AJAX request to get grid summary information + * * @return Nothing */ function sendGridSummaryAjax(){ - //get the summary data + //get the summary data $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -246,15 +246,14 @@ function sendGridSummaryAjax(){ } /** - * send ajax request to get nodes current load information - * - * @param which group name want to get + * Send AJAX request to get nodes current load information * * @return Nothing */ function sendNodeCurrentAjax(){ var groupname = $('#gangliagroup').val(); - //get all nodes current status + + //get all nodes current status $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -273,10 +272,8 @@ function sendNodeCurrentAjax(){ } /** - * send ajax request to get grid current summary information for update the page - * - * @param - * + * Send AJAX request to get grid current summary information for update the page + * * @return Nothing */ function sendGridCurrentAjax(){ @@ -299,7 +296,7 @@ function sendGridCurrentAjax(){ } /** - * save the grid summary data to local global variable + * Save the grid summary data to local global variable * * @param data structure * metric1:time11,val11,time12,val12....;metric2:time21,val21,time22,val22,...;.... @@ -329,7 +326,7 @@ function createGridSummaryData(summaryString){ } /** - * update the grid summary data to local global variable + * Update the grid summary data to local global variable * * @param data structure * metric1:time11,val11;metric2:time21,val21,time22;.... @@ -344,11 +341,11 @@ function updateGridSummaryData(currentString){ var tempArray; tempLength = metricArray.length; - for (index = 0; index < tempLength; index++){ + for (index = 0; index < tempLength; index++) { position = metricArray[index].indexOf(':'); metricname = metricArray[index].substr(0, position); tempArray = metricArray[index].substr(position + 1).split(','); - if (gridData[metricname]){ + if (gridData[metricname]) { gridData[metricname].shift(); gridData[metricname].shift(); gridData[metricname].push(Number(tempArray[0])); @@ -357,10 +354,8 @@ function updateGridSummaryData(currentString){ } } /** - * draw the Grid summay area by global data + * Draw the grid summay area by global data * - * @param data - * Data returned from HTTP request * @return Nothing */ function drawGridSummary() { @@ -369,13 +364,14 @@ function drawGridSummary() { var tempStr = $('#gangliamon').attr('class'); //jqflot only draw on the area visiable, if the tab is hide, return directly - if (-1 != tempStr.indexOf('hide')){ - return; - }; - - if ('[Show]' == $('#gangliamon #hidesup').text()){ + if (tempStr.indexOf('hide') != -1){ return; } + + if ($('#gangliamon #hidesup').text() == '[Show]'){ + return; + } + gridDrawArea.empty(); showStr = '' + '' + @@ -392,26 +388,26 @@ function drawGridSummary() { } /** - * draw the load flot by data(maybe summary data, or one node's data) + * Draw the load flot by data(summary data, or one node's data) * - * @param areaid: which div draw this flot - * loadpair: the load timestamp and value pair - * cpupair: the cpu number and value pair - * + * @param areaid + * Which DIV draw this flot + * @param loadpair + * The load timestamp and value pair + * @param cpupair + * The CPU number and value pair * @return Nothing */ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ var load = new Array(); var cpunum = new Array(); var index = 0; - var templength = 0; var yaxismax = 0; var interval = 1; $('#' + areaid).empty(); //parse load pair, the timestamp must mutiply 1000, javascript time stamp is millisecond - templength = loadpair.length; - for (index = 0; index < templength; index += 2){ + for (index = 0; index < loadpair.length; index += 2){ load.push([loadpair[index] * 1000, loadpair[index + 1]]); if (loadpair[index + 1] > yaxismax){ yaxismax = loadpair[index + 1]; @@ -419,8 +415,7 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ } //parse cpu pair - templength = cpupair.length; - for (index = 0; index < templength; index += 2){ + for (index = 0; index < cpupair.length; index += 2){ cpunum.push([cpupair[index] * 1000, cpupair[index + 1]]); if (cpupair[index + 1] > yaxismax){ yaxismax = cpupair[index + 1]; @@ -431,6 +426,7 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ if (interval < 1){ interval = 1; } + $.jqplot(areaid, [load, cpunum],{ title: titleprefix + ' Loads/Procs Last Hour', axes:{ @@ -458,24 +454,25 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ } /** - * draw the cpu usage flot by data(maybe summary data, or one node's data) + * Draw the CPU usage flot by data(maybe summary data, or one node's data) * - * @param areaid: which div draw this flot - * titleprefix : title used name - * cpupair: the cpu timestamp and value pair - * + * @param areaid + * Which DIV draw this flot + * @param titleprefix + * Title used name + * @param cpupair + * The CPU timestamp and value pair * @return Nothing */ function drawCpuFlot(areaid, titleprefix, cpupair){ var cpu = new Array(); var index = 0; - var tempLength = 0; $('#' + areaid).empty(); - tempLength = cpupair.length; + // time stamp should mutiply 1000 - // we get the cpu idle from server, we should use 1 subtract the idle. - for(index = 0; index < tempLength; index +=2){ + // we get the CPU idle from server, we should use 1 subtract the idle + for (index = 0; index < cpupair.length; index +=2) { cpu.push([(cpupair[index] * 1000), (100 - cpupair[index + 1])]); } @@ -502,12 +499,14 @@ function drawCpuFlot(areaid, titleprefix, cpupair){ } /** - * draw the memory usage flot by data(maybe summary data, or one node's data) + * Draw the memory usage flot by data(summary data, or one node's data) * - * @param areaid: which div draw this flot - * titleprefix : title used name - * cpupair: the cpu timestamp and value pair - * + * @param areaid + * Which DIV draw this flot + * @param titleprefix + * Title used name + * @param cpupair + * The CPU timestamp and value pair * @return Nothing */ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ @@ -517,14 +516,13 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ var index = 0; $('#' + areaid).empty(); - if(freepair.length < totalpair.length){ + if (freepair.length < totalpair.length) { tempsize = freepair.length; - } - else{ + } else { tempsize = freepair.length; } - for(index = 0; index < tempsize; index += 2){ + for (index = 0; index < tempsize; index += 2) { var temptotal = totalpair[index + 1]; var tempuse = temptotal - freepair[index + 1]; temptotal = temptotal / 1000000; @@ -560,13 +558,16 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ } /** - * draw the disk usage flot by data(maybe summary data, or one node's data) + * Draw the disk usage flot by data(summary data, or one node's data) * - * @param areaid: which div draw this flot - * titleprefix : title used name - * freepair: the free disk number, ganglia only log the free data - * totalpair: the all disk number - * + * @param areaid + * Which div draw this flot + * @param titleprefix + * Title used name + * @param freepair + * The free disk number, Ganglia only logs the free data + * @param totalpair + * The total disk number * @return Nothing */ function drawDiskFlot(areaid, titleprefix, freepair, totalpair){ @@ -616,52 +617,58 @@ function drawDiskFlot(areaid, titleprefix, freepair, totalpair){ ); } +/** + * Draw the network load flot by data(summary data, or one node's data) + * + * @param areaid + * Which div draw this flot + * @param titleprefix + * Title used name + * @param inpair + * The timestamp and value pair for download + * @param outpair + * The timestamp and value pair for upload + * @return Nothing + */ function drawNetworkFlot(areaid, titleprefix, inpair, outpair){ var inArray = new Array(); var outArray = new Array(); - var templength = 0; var index = 0; var maxvalue = 0; var unitname = 'B'; var divisor = 1; - templength = inpair.length; - for (index = 0; index < templength; index += 2){ - if (inpair[index + 1] > maxvalue){ + for (index = 0; index < inpair.length; index += 2) { + if (inpair[index + 1] > maxvalue) { maxvalue = inpair[index + 1]; } } - templength = outpair.length; - for (index = 0; index < templength; index += 2){ - if (outpair[index + 1] > maxvalue){ + for (index = 0; index < outpair.length; index += 2) { + if (outpair[index + 1] > maxvalue) { maxvalue = outpair[index + 1]; } } - if (maxvalue > 3000000){ + if (maxvalue > 3000000) { divisor = 1000000; unitname = 'GB'; - } - else if(maxvalue >= 3000){ + } else if (maxvalue >= 3000) { divisor = 1000; unitname = 'MB'; - } - else{ + } else { //do nothing } - templength = inpair.length; - for (index = 0; index < templength; index += 2){ + for (index = 0; index < inpair.length; index += 2) { inArray.push([(inpair[index] * 1000), (inpair[index + 1] / divisor)]); } - templength = outpair.length; - for (index = 0; index < templength; index += 2){ + for (index = 0; index < outpair.length; index += 2) { outArray.push([(outpair[index] * 1000), (outpair[index + 1] / divisor)]); } - $.jqplot(areaid, [inArray, outArray],{ + $.jqplot(areaid, [inArray, outArray], { title: titleprefix + ' Network Last Hour', axes:{ xaxis:{ @@ -683,10 +690,16 @@ function drawNetworkFlot(areaid, titleprefix, inpair, outpair){ }, series:[{label:'In'}, {label: 'Out'}], seriesDefaults : {showMarker: false} - } - ); + }); } +/** + * Create node status data + * + * @param nodesStatus + * Node status + * @return Nothing + */ function createNodeStatusData(nodesStatus){ var index; var nodesArray = nodesStatus.split(';'); @@ -695,53 +708,49 @@ function createNodeStatusData(nodesStatus){ var index = 0; var tempArray; var tempStr = ''; - var templength = nodesArray.length; - for (index in nodePath){ + for (index in nodePath) { delete(nodePath[index]); } - for (index in nodeStatus){ + for (index in nodeStatus) { delete(nodeStatus[index]); } - for (index = 0; index < templength; index++){ + for (index = 0; index < nodesArray.length; index++) { tempStr = nodesArray[index]; position = tempStr.indexOf(':'); nodename = tempStr.substring(0, position); tempArray = tempStr.substring(position + 1).split(','); - switch(tempArray[0]){ - case 'UNKNOWN':{ + switch (tempArray[0]) { + case 'UNKNOWN': nodeStatus[nodename] = -2; - } - break; - case 'ERROR':{ + break; + case 'ERROR': nodeStatus[nodename] = -1; - } - break; - case 'WARNING':{ + break; + case 'WARNING': nodeStatus[nodename] = 0; nodePath[nodename] = tempArray[1]; - } - break; - case 'NORMAL':{ + break; + case 'NORMAL': nodeStatus[nodename] = 1; nodePath[nodename] = tempArray[1]; - } - break; + break; } } } + /** - * draw nodes current status, there are four type: + * Draw nodes current status, there are four type: * a. unknown(gray): can not find save data for this node * b. error(red): get status sometime early, but can not get now * c. warning(orange): node are heavy load * d. normal(green): * - * @param - * + * @param ordertype + * Ascending or descending order * @return Nothing */ function drawGangliaNodesArea(ordertype){ @@ -751,51 +760,42 @@ function drawGangliaNodesArea(ordertype){ var nodename = ''; var sortarray = new Array(); $('#gangliaNodes').html(''); + //empty the hash - for (index in nodeStatus){ + for (index in nodeStatus) { sortarray.push([index, nodeStatus[index]]); } - if ('asc' == ordertype){ + if ('asc' == ordertype) { sortarray.sort(statusAsc); - } - else if('des' == ordertype){ + } else if('des' == ordertype) { sortarray.sort(statusDes); - } - else{ + } else { //do nothing } templength = sortarray.length; - for (index = 0; index < templength; index++){ + for (index = 0; index < templength; index++) { nodename = sortarray[index][0]; - switch(sortarray[index][1]){ - case -2:{ - showStr = '
  • '; - } - break; - case -1:{ - showStr = '
  • '; - } - break; - case 0:{ - showStr = '
  • '; - } - break; - case 1:{ - showStr = '
  • '; - } - break; + switch (sortarray[index][1]) { + case -2: + showStr = '
  • '; + break; + case -1: + showStr = '
  • '; + break; + case 0: + showStr = '
  • '; + break; + case 1: + showStr = '
  • '; + break; } $('#gangliaNodes ul').append(showStr); } //bind all normal and warning nodes' click event - $('.monitornormal,.monitorwarning').bind('click', function(){ + $('.monitornormal,.monitorwarning').bind('click', function() { var nodename = $(this).attr('title'); window.open('ganglianode.php?n=' + nodename + '&p=' + nodePath[nodename], 'nodedetail','height=430,width=950,scrollbars=yes,status =no'); @@ -804,14 +804,12 @@ function drawGangliaNodesArea(ordertype){ } /** - * update all tab per minute. + * Update all tab per minute. * - * @param - * * @return Nothing */ function updateGangliaPage(){ - if ($('#gangliaNodes').size() < 1){ + if ($('#gangliaNodes').size() < 1) { return; } @@ -821,10 +819,10 @@ function updateGangliaPage(){ gangliaTimer = window.setTimeout('updateGangliaPage()', 60000); } -function statusAsc(a, b){ +function statusAsc(a, b) { return a[1] - b[1]; } -function statusDes(a, b){ +function statusDes(a, b) { return b[1] - a[1]; } \ No newline at end of file diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index 1b69757e1..fd43f0e59 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -120,19 +120,19 @@ function loadMonitorPage() { } var monTable = $('
    '); - monTable.append($('Monitor ToolStatusDescription')); + monTable.append($('ToolStatusDescription')); var monTableBody = $(''); monTable.append(monTableBody); var xcatMon = $(''); - xcatMon.append($('xCAT Monitor')); + xcatMon.append($('xCAT')); xcatMon.append($('').append(statusButtonHash['xcatmon'])); xcatMon.append($('Provides node status monitoring using fping on AIX and nmap on Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.')); monTableBody.append(xcatMon); var rmcMon = $(''); - rmcMon.append($('RMC Monitor')); + rmcMon.append($('RMC')); rmcMon.append($('').append(statusButtonHash['rmcmon'])); rmcMon.append($('IBM\'s Resource Monitoring and Control (RMC) subsystem is our recommended software for monitoring xCAT clusters. It\'s is part of the IBM\'s Reliable Scalable Cluster Technology (RSCT) that provides a comprehensive clustering environment for AIX and Linux.')); monTableBody.append(rmcMon); @@ -144,13 +144,13 @@ function loadMonitorPage() { monTableBody.append(rmcEvent); var gangliaMon = $(''); - gangliaMon.append($('Ganglia Monitor')); + gangliaMon.append($('Ganglia')); gangliaMon.append($('').append(statusButtonHash['gangliamon'])); gangliaMon.append($('A scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.')); monTableBody.append(gangliaMon); var pcpMon = $(''); - pcpMon.append($('PCP Monitor')); + pcpMon.append($('PCP')); pcpMon.append($('').append(statusButtonHash['pcpmon'])); pcpMon.append($('Under construction.')); monTableBody.append(pcpMon); diff --git a/xCAT-UI/js/monitor/rmcmon.js b/xCAT-UI/js/monitor/rmcmon.js index f3638e98b..bb396fa21 100644 --- a/xCAT-UI/js/monitor/rmcmon.js +++ b/xCAT-UI/js/monitor/rmcmon.js @@ -14,14 +14,13 @@ function loadRmcMon() { rmcStatusBar.find('div').append(createLoader()); rmcMonTab.append(rmcStatusBar); - //add the configure button. + //add the configure button var configButton = createButton('Configure'); configButton.hide(); configButton.click(function() { if ($('#rmcMonConfig').is(':hidden')) { $('#rmcMonConfig').show(); - } - else { + } else { $('#rmcMonConfig').hide(); } }); @@ -39,18 +38,18 @@ function loadRmcMon() { $('#nodeDetail').hide(); //check the software work status by platform(linux and aix) - $.ajax( { - url : 'lib/systemcmd.php', - dataType : 'json', - data : { - cmd : 'ostype' + $.ajax({ + url: 'lib/systemcmd.php', + dataType: 'json', + data: { + cmd: 'ostype' }, - success : rsctRpmCheck + success: rsctRpmCheck }); } -function loadRmcMonConfigure(){ +function loadRmcMonConfigure() { //get the configure div and clean its content. var rmcmonCfgDiv = $('#rmcMonConfig'); rmcmonCfgDiv.empty(); @@ -61,13 +60,13 @@ function loadRmcMonConfigure(){ startButton.click(function(){ $('#rmcMonStatus div').empty().append(createLoader()); $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : 'rmcstart;compute', - msg : '' + url: 'lib/cmd.php', + dataType: 'json', + data: { + cmd: 'webrun', + tgt: '', + args: 'rmcstart;compute', + msg: '' }, success : function(data){ @@ -79,19 +78,19 @@ function loadRmcMonConfigure(){ //add the stop button var stopButton = createButton('Stop'); rmcmonCfgDiv.append(stopButton); - stopButton.click(function(){ + stopButton.click(function() { $('#rmcMonStatus div').empty().append(createLoader()); $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'monstop', - tgt : '', - args : 'rmcmon', - msg : '' + url: 'lib/cmd.php', + dataType: 'json', + data: { + cmd: 'monstop', + tgt: '', + args: 'rmcmon', + msg: '' }, - success : function(data){ + success: function(data) { $('#rmcMonStatus div').empty().append(data.rsp[0]); } }); @@ -100,93 +99,90 @@ function loadRmcMonConfigure(){ //add the cancel button var cancelButton = createButton('Cancel'); rmcmonCfgDiv.append(cancelButton); - cancelButton.click(function(){ + cancelButton.click(function() { $('#rmcMonConfig').hide(); }); } -function rsctRpmCheck(data){ +function rsctRpmCheck(data) { //linux had to check the rscp first - if ('aix' != data.rsp){ - $.ajax( { - url : 'lib/systemcmd.php', - dataType : 'json', - data : { - cmd : 'rpm -q rsct.core' + if ('aix' != data.rsp) { + $.ajax({ + url: 'lib/systemcmd.php', + dataType: 'json', + data: { + cmd: 'rpm -q rsct.core' }, - success : function(data){ - if (-1 != data.rsp.indexOf("not")){ + success: function(data) { + if (-1 != data.rsp.indexOf("not")) { $('#rmcMonStatus div').empty().append( 'Please install the RSCT first.
    ' + 'You can find more support from xCAT2-Monitoring.pdf'); - } - else{ + } else { xcatrmcRpmCheck(); } } }); - } - else{ + } else { xcatrmcRpmCheck(); } } -function xcatrmcRpmCheck(){ - $.ajax( { +function xcatrmcRpmCheck() { + $.ajax({ url : 'lib/systemcmd.php', dataType : 'json', data : { cmd : 'rpm -q xCAT-rmc rrdtool' }, - success : function(data){ + success : function(data) { var softInstallStatus = data.rsp.split(/\n/); var needHelp = false; $('#rmcMonStatus div').empty(); //check the xcat-rmc - if (-1 != softInstallStatus[0].indexOf("not")){ + if (-1 != softInstallStatus[0].indexOf("not")) { needHelp = true; $('#rmcMonStatus div').append( 'Please install the xCAT-rmc first.
    '); } //check the rrdtool - if (-1 != softInstallStatus[1].indexOf("not")){ + if (-1 != softInstallStatus[1].indexOf("not")) { needHelp = true; $('#rmcMonStatus div').append( 'Please install the RRD-tool first.
    '); } //add help info or load the rmc show - if (needHelp){ + if (needHelp) { $('#rmcMonStatus div').append( 'You can find more support form xCAT2-Monitoring.pdf'); - } - else{ + } else { rmcWorkingCheck(); } } }); } -function rmcWorkingCheck(){ - $('#rmcMonStatus div').empty().append("Checking RMC working status."); +function rmcWorkingCheck() { + $('#rmcMonStatus div').empty().append("Checking RMC working status"); $('#rmcMonStatus div').append(createLoader()); $('#rmcmon button:first').show(); $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'monls', - tgt : '', - args : 'rmcmon', - msg : '' + url: 'lib/cmd.php', + dataType: 'json', + data: { + cmd: 'monls', + tgt: '', + args: 'rmcmon', + msg: '' }, - success : function(data){ + success: function(data) { if (-1 != data.rsp[0].indexOf("not-monitored")){ - $('#rmcMonStatus div').empty().append("Please start the RMC Monitoring first."); + $('#rmcMonStatus div').empty().append("Please start the RMC Monitoring first"); return; } loadRmcMonShow(); @@ -203,21 +199,21 @@ function removeStatusBar(){ } function loadRmcMonShow(){ - $('#rmcMonStatus div').empty().append("Getting Summary Data."); + $('#rmcMonStatus div').empty().append("Getting summary data"); $('#rmcMonStatus div').append(createLoader()); //load the rmc status summary $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : 'rmcshow;summary;PctTotalTimeIdle,PctRealMemFree', - msg : '' + url: 'lib/cmd.php', + dataType: 'json', + data: { + cmd: 'webrun', + tgt: '', + args: 'rmcshow;summary;PctTotalTimeIdle,PctRealMemFree', + msg: '' }, - success : function(data){ + success: function(data) { showRmcSummary(data.rsp[0]); } }); @@ -234,19 +230,19 @@ function showRmcSummary(returnData) { globalTimeStamp = new Array(); //update the rmc status area - $('#rmcMonStatus div').empty().append("Getting Nodes' Data").append(createLoader()); + $('#rmcMonStatus div').empty().append("Getting nodes data").append(createLoader()); //load each nodes' status - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : 'rmcshow;compute;PctTotalTimeIdle,PctRealMemFree', - msg : '' + $.ajax({ + url: 'lib/cmd.php', + dataType: 'json', + data: { + cmd: 'webrun', + tgt: '', + args: 'rmcshow;compute;PctTotalTimeIdle,PctRealMemFree', + msg: '' }, - success : function(data) { + success: function(data) { parseRmcData(data.rsp); } }); @@ -256,7 +252,7 @@ function showRmcSummary(returnData) { var tempDate = new Date(); var tempOffset = tempDate.getTimezoneOffset(); var tempTime = tempDate.getTime() - 3600000; - for ( var i = 0; i < 60; i++) { + for (var i = 0; i < 60; i++) { tempDate.setTime(tempTime + i * 60000); globalTimeStamp.push(tempDate.getTime()); } @@ -279,29 +275,29 @@ function showRmcSummary(returnData) { summaryRow.append(tempTd); attrDiv = $('
    '); tempTd.append(attrDiv); - for ( var i in attrValues) { + for (var i in attrValues) { tempArray.push( [ globalTimeStamp[i], Number(attrValues[i]) ]); } $.jqplot('monitorsumdiv' + attr, [ tempArray ], { - series : [ { + series: [{ showMarker : false - } ], - axes : { - xaxis : { - label : attrName, - renderer : $.jqplot.DateAxisRenderer, - numberTicks : 5, - tickOptions : { - formatString : '%R', - show : true, - fontSize : '10px' + }], + axes: { + xaxis: { + label: attrName, + renderer: $.jqplot.DateAxisRenderer, + numberTicks: 5, + tickOptions: { + formatString: '%R', + show: true, + fontSize: '10px' } }, - yaxis : { - tickOptions : { - formatString : '%.2f', - fontSize : '10px' + yaxis: { + tickOptions: { + formatString: '%.2f', + fontSize: '10px' } } } @@ -309,7 +305,7 @@ function showRmcSummary(returnData) { } } -function parseRmcData(returnData){ +function parseRmcData(returnData) { var nodeName; var nodeStatus; @@ -323,12 +319,12 @@ function parseRmcData(returnData){ globalAllNodesNum = returnData.length; globalFinishNodesNum = 0; - for(var i in returnData){ + for (var i in returnData) { var temp = returnData[i].indexOf(':');; nodeName = returnData[i].substr(0, temp); nodeStatus = returnData[i].substr(temp + 1).replace(/(^\s*)|(\s*$)/g, ''); - if ('OK' != nodeStatus){ + if ('OK' != nodeStatus) { globalFinishNodesNum++; detailUl.append(createUnkownNode(nodeName)); removeStatusBar(); @@ -351,13 +347,13 @@ function parseRmcData(returnData){ } } -function createUnkownNode(nodeName){ +function createUnkownNode(nodeName) { var tempLi = '
  • '; return tempLi; } -function createErrorNode(nodeName){ +function createErrorNode(nodeName) { var tempLi = '
  • '; } @@ -370,14 +366,14 @@ function showRmcNodes(data, nodename) { var classname = ''; var tempObj = {}; - for (index in data){ + for (index in data) { position = data[index].indexOf(':'); attrname = data[index].substr(0, position); values = data[index].substr(position + 1); //error node, can not get the last hour's data - if ('' == values){ + if (!values) { $('#rmcmonDetail ul').append(createErrorNode(nodename)); - if (globalNodesDetail[nodename]){ + if (globalNodesDetail[nodename]) { delete(globalNodesDetail[nodename]); } return; @@ -394,22 +390,21 @@ function showRmcNodes(data, nodename) { var memAvg = 0; var tempSum = 0; var tempArray = globalNodesDetail[nodename]['PctTotalTimeIdle'].split(','); - for (index = 0; index < tempArray.length; index++){ + for (index = 0; index < tempArray.length; index++) { tempSum += Number(tempArray[index]); } cpuAvg = parseInt(tempSum / index); tempArray = globalNodesDetail[nodename]['PctRealMemFree'].split(','); tempSum = 0; - for (index = 0; index < tempArray.length; index++){ + for (index = 0; index < tempArray.length; index++) { tempSum += Number(tempArray[index]); } memAvg = parseInt(tempSum / index); if (cpuAvg >= 10 && memAvg <= 90){ classname = 'monitornormal'; - } - else{ + } else { classname = 'mornitorwarning'; } @@ -463,9 +458,9 @@ function showNode(nodeName) { } $.jqplot('monitornodediv' + nodeName + attr, [ tempArray ], { - series : [ { + series : [{ showMarker : false - } ], + }], axes : { xaxis : { label : attr, @@ -488,14 +483,10 @@ function showNode(nodeName) { } } -/*===========RMC Event Tab============*/ /** - * load the rmc event tab. - * - * @param - * - * @return + * load the rmc event tab * + * @return nothing */ function loadRmcEvent(){ //find the rmcevent tab @@ -506,7 +497,7 @@ function loadRmcEvent(){ $('#rmcevent').append(rmcStatusBar); $('#rmcevent').append('
    '); - $.ajax( { + $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { @@ -523,11 +514,10 @@ function loadRmcEvent(){ /** * get all conditions * - * @return - * + * @return nothing */ function getConditions(){ - if ('' == globalCondition){ + if (!globalCondition) { $('#rmcEventStatus div').empty().append('Getting predefined conditions').append(createLoader()); $.ajax({ url : 'lib/cmd.php', @@ -545,8 +535,7 @@ function getConditions(){ globalCondition = data.rsp[0]; } }); - } - else{ + } else { $('#rmcEventButtons').show(); } } @@ -554,18 +543,17 @@ function getConditions(){ /** * get all response * - * @return - * + * @return nothing */ -function getResponse(){ +function getResponse() { var tempFlag = false; //get all response first - for (var i in globalResponse){ + for (var i in globalResponse) { tempFlag = true; break; } - if (!tempFlag){ + if (!tempFlag) { $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -576,9 +564,9 @@ function getResponse(){ msg : '' }, - success : function(data){ + success : function(data) { var resps = data.rsp[0].split(';'); - for (var i in resps){ + for (var i in resps) { var name = resps[i]; name = name.substr(1, (name.length - 2)); globalResponse[name] = 1; @@ -591,24 +579,20 @@ function getResponse(){ /** * show all the event in the rmc event tab * - * @param data response from the xcat server. - - * @return - * + * @param data + * response from the xcat server + * @return nothing */ -function showEventLog(data){ +function showEventLog(data) { $('#rmcEventStatus div').empty(); // rsct not installed. - if (data.rsp[0] && (-1 != data.rsp[0].indexOf('lsevent'))){ + if (data.rsp[0] && (-1 != data.rsp[0].indexOf('lsevent'))) { $('#rmcEventStatus div').append('Please install RSCT first!'); return; } var eventDiv = $('#rmcEventDiv'); eventDiv.empty(); - - //add the configure button - loadRmcEventConfig(); - + //get conditions and responses, save in the global getConditions(); getResponse(); @@ -616,80 +600,87 @@ function showEventLog(data){ var eventTable = new DataTable('lsEventTable'); eventTable.init(['Time', 'Type', 'Content']); - for (var i in data.rsp){ + for (var i in data.rsp) { var row = data.rsp[i].split(';'); eventTable.add(row); } eventDiv.append(eventTable.object()); $('#lsEventTable').dataTable({ - 'bFilter' : true, - 'bLengthChange' :true, - 'bSort' :true, - 'bPaginate' :true, - 'iDisplayLength' :10 + 'iDisplayLength': 50, + 'bLengthChange': false, + "sScrollX": "100%", + "bAutoWidth": true }); + //add the configure button + loadRmcEventConfig(); + //unsort on the content column $('#lsEventTable thead tr th').eq(2).unbind('click'); } /** * Add the configure button into rmc event tab - * - * @param - - * @return - * + * + * @return nothing */ function loadRmcEventConfig(){ - var buttons = $(''); - var chCondScopeBut = createButton('Change Condition Scope'); - chCondScopeBut.bind('click', function(){ + //create action bar + var actionBar = $('
    '); + var chCondScopeLnk = $('Change condition scope'); + chCondScopeLnk.bind('click', function() { chCondScopeDia(); }); - buttons.append(chCondScopeBut); - var mkCondRespBut = createButton('Make/Remove Association'); - mkCondRespBut.bind('click', function(){ + var mkCondRespLnk = $('Make/remove associatione'); + mkCondRespLnk.bind('click', function() { mkCondRespDia(); }); - buttons.append(mkCondRespBut); - var startCondRespBut = createButton('Start/Stop Association'); - startCondRespBut.bind('click', function(){ + var startCondRespLnk = $('Start/stop association'); + startCondRespLnk.bind('click', function() { startStopCondRespDia(); }); - buttons.append(startCondRespBut); - $('#rmcEventDiv').append(buttons); + //actions + var actionsLnk = 'Actions'; + var actsMenu = createMenu([chCondScopeLnk, mkCondRespLnk, startCondRespLnk]); + + //create an action menu + var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]); + actionsMenu.superfish(); + actionsMenu.css('display', 'inline-block'); + actionBar.append(actionsMenu); + + //create a division to hold actions menu + var menuDiv = $(''); + $('#lsEventTable_wrapper').prepend(menuDiv); + menuDiv.append(actionBar); + $('#lsEventTable_filter').appendTo(menuDiv); } /** * show the make association dialogue * - * @param - - * @return - * + * @return nothing */ function mkCondRespDia(){ var diaDiv = $('
    '); var mkAssociationTable = '
    '; mkAssociationTable += '
    Condition NameResponse Name
    '; //add the conditions into fieldset - if ('' == globalCondition){ - mkAssociationTable += 'Getting predefined conditions, open this dislogue later.'; - } - else{ + if (!globalCondition) { + mkAssociationTable += 'Getting predefined conditions, open this dislogue later'; + } else { mkAssociationTable += createConditionTd(globalCondition); } - mkAssociationTable += 'Plase select condition first.
    '; + mkAssociationTable += 'Please select condition first'; diaDiv.append(mkAssociationTable); diaDiv.append('