From 612ad8c52deab0affc5f1a086fccb009f86e3c5b Mon Sep 17 00:00:00 2001 From: phamt Date: Wed, 8 Feb 2012 15:49:36 +0000 Subject: [PATCH] Cleaned up Ganglia page and enabled other nodes to show up in Current Nodes Status table git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11513 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/gangliamon.js | 483 +++++++++++++++---------------- xCAT-UI/xcat/plugins/web.pm | 2 +- 2 files changed, 238 insertions(+), 247 deletions(-) diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js index 4e2b6c746..e8896c527 100644 --- a/xCAT-UI/js/monitor/gangliamon.js +++ b/xCAT-UI/js/monitor/gangliamon.js @@ -1,39 +1,40 @@ /** * Global variables */ -//save grid summary data, update every one minute + +// Save grid summary data, update every one minute var gridData; -//save nodes path, used for getting detail from rrd file +// Save nodes path, used for getting detail from rrd file var nodePath = new Object(); -//save nodes current status, -//unknown-> -2, error->-1, warning->0 ,normal->1 which is used for sorting +// Save nodes current status, +// unknown = -2, error = -1, warning = 0 ,normal = 1 are used for sorting var nodeStatus = new Object(); -//update timer +// Update timer var gangliaTimer; -//global frame hash +// Global frame hash var framehash; -//global cec hash +// Global cec hash var cechash; -//global blade hash +// Global blade hash var bladehash; -//global x rack hash +// Global x rack hash var rackhash; -//global other type node hash +// Global other type node hash var otherhash; + /** * Load Ganglia monitoring tool * * @return Nothing */ function loadGangliaMon() { - // Get Ganglia tab $('#gangliamon').append(createInfoBar('Checking RPMs')); - //should get the groups first + // Get groups and set cookie if (!$.cookie('groups')) { $.ajax( { url : 'lib/cmd.php', @@ -48,6 +49,7 @@ function loadGangliaMon() { success : setGroupsCookies }); } + // Check whether Ganglia RPMs are installed on the xCAT MN $.ajax({ url : 'lib/systemcmd.php', @@ -74,7 +76,7 @@ function checkGangliaRPMs(data) { // Get the list of Ganglia RPMs installed var status = data.rsp.split(/\n/); - var gangliaRPMs = [ "rrdtool", "ganglia-gmetad", "ganglia-gmond"]; + var gangliaRPMs = ["rrdtool", "ganglia-gmetad", "ganglia-gmond"]; var warningMsg = 'Before continuing, please install the following packages: '; var missingRPMs = false; for (var i in status) { @@ -86,8 +88,6 @@ function checkGangliaRPMs(data) { // Append Ganglia PDF if (missingRPMs) { - warningMsg += ". Refer to xCAT2-Monitoring.pdf for more information."; - var warningBar = createWarnBar(warningMsg); warningBar.css('margin-bottom', '10px'); warningBar.prependTo(gangliaTab); @@ -119,15 +119,15 @@ function checkGangliaRPMs(data) { * Data returned from HTTP request * @return Nothing */ -function checkGangliaRunning(data){ +function checkGangliaRunning(data) { var gangliaTab = $('#gangliamon'); - var groupsSelectStr = ''; - var groupsArray = $.cookie('groups').split(','); gangliaTab.empty(); + + // If Ganglia is not started if (data.rsp[0].indexOf("not-monitored") > -1) { // Create link to start Ganglia var startLnk = $('Click here'); - startLnk.css( { + startLnk.css({ 'color' : 'blue', 'text-decoration' : 'none' }); @@ -165,41 +165,36 @@ function checkGangliaRunning(data){ return; } - //help info - var helpStr = '' + - '' + - '' + - '' + - '' + - '
Normal Heavy Load Error Unknown
'; + // Legend for node status + var legend = '' + + '' + + '' + + '' + + '' + + '
Normal Heavy Load Error Unknown
'; - //pass checking + // Gganglia grid overview var showStr = '

Grid Overview

' + '[Hide]

' + '
' + - '

Nodes Current Status

' + helpStr + '

' + + '

Current Nodes Status

' + legend + '

' + '
All Nodes
' + '
'; - - //ganglia help information - gangliaTab.append(showStr); - //get summary data and draw on the page + // Get summary data and draw on page $('#gangliaGridSummary').append('Getting grid summary data '); sendGridSummaryAjax(); - //get all nodes location data which can support the zoom monitor + // Get all nodes location data which can support the zoom monitor $('#gangliaNodes').append('Getting all nodes status '); sendLocationAjax(); - //bind the hide/show buttion event + // Bind the hide/show button event $('#gangliamon #hidesup').bind('click', function(){ - var a = $(this).text(); - if ('[Hide]' == $(this).text()){ + if ('[Hide]' == $(this).text()) { $(this).html('[Show]'); - } - else{ + } else { $(this).html('[Hide]'); } @@ -208,12 +203,11 @@ function checkGangliaRunning(data){ } /** - * Send AJAX request to get all nodes parent and - * position to create hardware hierarchy hash + * Send AJAX request to get all nodes parent and position to create hardware hierarchy hash * - * retrn : nothing + * @return Nothing */ -function sendLocationAjax(){ +function sendLocationAjax() { $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -225,26 +219,114 @@ function sendLocationAjax(){ }, success: function(data){ - if(!data.rsp[0]){ + if (!data.rsp[0]) { return; } + extractLocationlData(data.rsp[0]); - //get nodes current status and draw on the page + // Get nodes current status and draw on the page sendNodeCurrentAjax(); - //start the timer to update page per minute. + // Start the timer to update page per minute gangliaTimer = window.setTimeout('updateGangliaPage()', 60000); } }); } +/** + * Extract the location query data and saved in global variable + * + * @return Nothing + */ +function extractLocationlData(locationData) { + framehash = new Object(); + cechash = new Object(); + bladehash = new Object(); + rackhash = new Object(); + + // Linux nodes which has no parent + linuxArray = new Array(); + + // Other unknown nodes only have one parent, use number 1 as there parent + otherhash = new Object(); + otherhash[1] = new Array(); + + var allnodearray = locationData.split(';'); + var temparray; + var parent = ''; + var name = ''; + for (var i in allnodearray) { + temparray = allnodearray[i].split(':'); + name = temparray[0]; + + // If there is not parent (or mpa, or rack) information + parent = temparray[2]; + if (!parent) { + // Go to next node + continue; + } + + switch (temparray[1].toLowerCase()) { + case 'blade': { + if (!bladehash[parent]) { + bladehash[parent] = new Array(); + } + + bladehash[parent].push(name); + } + break; + + case 'systemx': { + if (!rackhash[parent]) { + rackhash[parent] = new Array(); + } + + rackhash[parent].push(name); + } + break; + + case 'frame': { + if (!framehash[name]) { + framehash[name] = new Array(); + } + } + break; + + case 'cec': { + if (!framehash[parent]) { + framehash[parent] = new Array(); + } + + framehash[parent].push(name); + } + break; + + case 'lpar': + case 'lpar,osi': + case 'osi,lpar': { + if (!cechash[parent]) { + cechash[parent] = new Array(); + } + + cechash[parent].push(name); + } + + break; + default: { + otherhash[1].push(name); + } + break; + } + } +} + /** * Send AJAX request to get grid summary information * * @return Nothing */ -function sendGridSummaryAjax(){ - //get the summary data +function sendGridSummaryAjax() { + // Get the summary data $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -255,7 +337,7 @@ function sendGridSummaryAjax(){ msg : '' }, - success: function(data){ + success: function(data) { createGridSummaryData(data.rsp[0]); drawGridSummary(); } @@ -267,9 +349,9 @@ function sendGridSummaryAjax(){ * * @return Nothing */ -function sendNodeCurrentAjax(){ +function sendNodeCurrentAjax() { - //get all nodes current status + // Get all nodes current status $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -288,12 +370,12 @@ function sendNodeCurrentAjax(){ } /** - * Send AJAX request to get grid current summary information for update the page + * Send AJAX request to get grid current summary information to update the page * * @return Nothing */ function sendGridCurrentAjax(){ - //get the summary data + // Get the summary data $.ajax({ url : 'lib/cmd.php', dataType : 'json', @@ -319,7 +401,7 @@ function sendGridCurrentAjax(){ * @return Nothing */ function createGridSummaryData(summaryString){ - //empty the global data + // Empty the global data gridData = new Object(); var metricArray = summaryString.split(';'); @@ -327,15 +409,17 @@ function createGridSummaryData(summaryString){ var valueArray = ''; var position = 0; var tempLength = 0; - for (var index = 0; index < metricArray.length; index++){ + for (var index = 0; index < metricArray.length; index++) { position = metricArray[index].indexOf(':'); - //get the metric name and init its global array to save timestamp and value pair + + // Get the metric name and init its global array to save timestamp and value pair metricname = metricArray[index].substr(0, position); gridData[metricname] = new Array(); valueArray = metricArray[index].substr(position + 1).split(','); tempLength = valueArray.length; - //save timestamp and value into global array - for (var i = 0; i < tempLength; i++){ + + // Save timestamp and value into global array + for (var i = 0; i < tempLength; i++) { gridData[metricname].push(Number(valueArray[i])); } } @@ -369,6 +453,7 @@ function updateGridSummaryData(currentString){ } } } + /** * Draw the grid summay area by global data * @@ -379,12 +464,13 @@ function drawGridSummary() { var showStr = ''; var tempStr = $('#gangliamon').attr('class'); - //jqflot only draw on the area visiable, if the tab is hide, return directly - if (tempStr.indexOf('hide') != -1){ + // jqflot only draws on the visible area + // If the tab is hide, return directly + if (tempStr.indexOf('hide') != -1) { return; } - if ($('#gangliamon #hidesup').text() == '[Show]'){ + if ($('#gangliamon #hidesup').text() == '[Show]') { return; } @@ -414,7 +500,7 @@ function drawGridSummary() { * The CPU number and value pair * @return Nothing */ -function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ +function drawLoadFlot(areaid, titleprefix, loadpair, cpupair) { var load = new Array(); var cpunum = new Array(); var index = 0; @@ -422,28 +508,28 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ var interval = 1; $('#' + areaid).empty(); - //parse load pair, the timestamp must mutiply 1000, javascript time stamp is millisecond - for (index = 0; index < loadpair.length; index += 2){ + // Parse load pair, the timestamp must mutiply 1000, javascript time stamp is millisecond + for (index = 0; index < loadpair.length; index += 2) { load.push([loadpair[index] * 1000, loadpair[index + 1]]); - if (loadpair[index + 1] > yaxismax){ + if (loadpair[index + 1] > yaxismax) { yaxismax = loadpair[index + 1]; } } - //parse cpu pair - for (index = 0; index < cpupair.length; index += 2){ + // Parse cpu pair + for (index = 0; index < cpupair.length; index += 2) { cpunum.push([cpupair[index] * 1000, cpupair[index + 1]]); - if (cpupair[index + 1] > yaxismax){ + if (cpupair[index + 1] > yaxismax) { yaxismax = cpupair[index + 1]; } } interval = parseInt(yaxismax / 3); - if (interval < 1){ + if (interval < 1) { interval = 1; } - $.jqplot(areaid, [load, cpunum],{ + $.jqplot(areaid, [load, cpunum], { title: titleprefix + ' Loads/Procs Last Hour', axes:{ xaxis:{ @@ -465,8 +551,7 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ }, series:[{label:'Load'}, {label: 'CPU Number'}], seriesDefaults : {showMarker: false} - } - ); + }); } /** @@ -480,14 +565,14 @@ function drawLoadFlot(areaid, titleprefix, loadpair, cpupair){ * The CPU timestamp and value pair * @return Nothing */ -function drawCpuFlot(areaid, titleprefix, cpupair){ +function drawCpuFlot(areaid, titleprefix, cpupair) { var cpu = new Array(); var index = 0; $('#' + areaid).empty(); - // time stamp should mutiply 1000 - // we get the CPU idle from server, we should use 1 subtract the idle + // Time stamp should be mutiplied by 1000 + // We get the CPU idle from server for (index = 0; index < cpupair.length; index +=2) { cpu.push([(cpupair[index] * 1000), (100 - cpupair[index + 1])]); } @@ -510,8 +595,7 @@ function drawCpuFlot(areaid, titleprefix, cpupair){ } }, seriesDefaults : {showMarker: false} - } - ); + }); } /** @@ -547,7 +631,7 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ use.push([freepair[index] * 1000, tempuse]); } - $.jqplot(areaid, [use, total],{ + $.jqplot(areaid, [use, total], { title: titleprefix + ' Memory Use Last Hour', axes:{ xaxis:{ @@ -569,8 +653,7 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ }, series:[{label:'Used'}, {label: 'Total'}], seriesDefaults : {showMarker: false} - } - ); + }); } /** @@ -586,28 +669,27 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ * The total disk number * @return Nothing */ -function drawDiskFlot(areaid, titleprefix, freepair, totalpair){ +function drawDiskFlot(areaid, titleprefix, freepair, totalpair) { var use = new Array(); var total = new Array(); var tempsize = 0; 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]; total.push([totalpair[index] * 1000, temptotal]); use.push([freepair[index] * 1000, tempuse]); } - $.jqplot(areaid, [use, total],{ + $.jqplot(areaid, [use, total], { title: titleprefix + ' Disk Use Last Hour', axes:{ xaxis:{ @@ -629,8 +711,7 @@ function drawDiskFlot(areaid, titleprefix, freepair, totalpair){ }, series:[{label:'Used'}, {label: 'Total'}], seriesDefaults : {showMarker: false} - } - ); + }); } /** @@ -646,7 +727,7 @@ function drawDiskFlot(areaid, titleprefix, freepair, totalpair){ * The timestamp and value pair for upload * @return Nothing */ -function drawNetworkFlot(areaid, titleprefix, inpair, outpair){ +function drawNetworkFlot(areaid, titleprefix, inpair, outpair) { var inArray = new Array(); var outArray = new Array(); var index = 0; @@ -716,8 +797,7 @@ function drawNetworkFlot(areaid, titleprefix, inpair, outpair){ * Node status * @return Nothing */ -function createNodeStatusData(nodesStatus){ - var index; +function createNodeStatusData(nodesStatus) { var nodesArray = nodesStatus.split(';'); var position = 0; var nodename = ''; @@ -747,41 +827,41 @@ function createNodeStatusData(nodesStatus){ /** * 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): + * a. unknown(gray): cannot find save data for this node + * b. error(red): got status sometime earlier, but cannot get now + * c. warning(orange): heavy load + * d. normal(green): normal load * - * @param * @return Nothing */ -function drawGangliaNodesArea(){ +function drawGangliaNodesArea() { var position = 0; - // find out the last child's type and name + + // Find out the last child's type and name var currentobj = $('#zoomDiv span:last'); var type = currentobj.attr('name').toLowerCase(); var name = currentobj.text(); position = name.indexOf('('); - if (position > -1){ + + if (position > -1) { name = name.substr(3, position - 3); } $('#gangliaNodes').empty(); - switch (type){ - //these type draw the node current status + switch (type) { + // Draw the node current status case 'blade': case 'cec': case 'rack': - case 'other': - { + case 'other': { drawGangliaNodesAreaPic(type, name); } break; - //these type draw a summary table + + // Draw a summary table case 'all': - case 'frame': - { - drawGangliaNodesAreaTab(type, name); + case 'frame': { + drawGangliaNodesAreaTable(type, name); } break; default: @@ -789,31 +869,27 @@ function drawGangliaNodesArea(){ } } -function drawGangliaNodesAreaPic(type, name){ +function drawGangliaNodesAreaPic(type, name) { var index = 0; - var arraypoint; + var arraypoint = ''; var templength = 0; var showStr = ''; var nodename = ''; - switch(type){ - case 'blade': - { + switch(type) { + case 'blade': { arraypoint = bladehash[name]; } break; - case 'cec': - { + case 'cec': { arraypoint = cechash[name]; } break; - case 'rack': - { + case 'rack': { arraypoint = rackhash[name]; } break; - case 'other': - { + case 'other': { arraypoint = otherhash[1]; } default: @@ -842,7 +918,7 @@ function drawGangliaNodesAreaPic(type, name){ $('#gangliaNodes ul').append(showStr); } - //bind all normal and warning nodes' click event + // Bind all normal and warning nodes click event $('.monitornormal,.monitorwarning').bind('click', function() { var nodename = $(this).attr('title'); window.open('ganglianode.php?n=' + nodename + '&p=' + nodePath[nodename], @@ -850,63 +926,64 @@ function drawGangliaNodesAreaPic(type, name){ }); } -function drawGangliaNodesAreaTab(type, name){ - var tabobj = $('
'); - var rowstr = ''; - var usedcec = new Object(); - tabobj.append('NameTypeNormalHeavy LoadErrorUnknown'); - if ('all' == type){ - for(var i in framehash){ +function drawGangliaNodesAreaTable(type, name) { + var table = $('
'); + var row = ''; + var usedCec = new Object(); + + var header = $(' NameTypeNormalHeavy LoadErrorUnknown '); + table.append(header); + + if (type == 'all') { + for (var i in framehash) { var framename = i; - rowstr = '' + framename + 'Frame' + + row = '' + framename + 'Frame' + monitorStatAgg('frame', framehash[i]) + ''; - tabobj.append(rowstr); + table.append(row); for(var j in framehash[i]){ - usedcec[framehash[i][j]] = 1; + usedCec[framehash[i][j]] = 1; } } - for (var i in cechash){ - if (usedcec[i]){ + for (var i in cechash) { + if (usedCec[i]) { continue; } var cecname = i; - rowstr = '' + cecname + 'CEC' + + row = '' + cecname + 'CEC' + monitorStatAgg('cec', cechash[i]) + ''; - tabobj.append(rowstr); + table.append(row); } - for (var i in bladehash){ + for (var i in bladehash) { var bladename = i; - rowstr = '' + bladename + 'Blade' + + row = '' + bladename + 'Blade' + monitorStatAgg('blade', bladehash[i]) + ''; - tabobj.append(rowstr); + table.append(row); } - for (var i in rackhash){ + for (var i in rackhash) { var rackname = i; - rowstr = '' + rackname + 'Rack' + + row = '' + rackname + 'Rack' + monitorStatAgg('rack', rackhash[i]) + ''; - tabobj.append(rowstr); + table.append(row); } - if (otherhash[1].length > 0) - { - rowstr = 'OtherOther' + + if (otherhash[1].length > 0) { + row = 'OtherOther' + monitorStatAgg('other', otherhash[1]) + ''; - tabobj.append(rowstr); + table.append(row); } - } - else{ - for (var i in framehash[name]){ + } else { + for (var i in framehash[name]) { var cecname = framehash[name][i]; - rowstr = '' + cecname + '' + + row = '' + cecname + '' + 'CEC' + monitorStatAgg('cec', cechash[cecname]) + ''; - tabobj.append(rowstr); + table.append(row); } } - $('#gangliaNodes').append(tabobj); + $('#gangliaNodes').append(table); } /** @@ -914,7 +991,7 @@ function drawGangliaNodesAreaTab(type, name){ * * @return Nothing */ -function monitorStatAgg(type, inputarray){ +function monitorStatAgg(type, inputarray) { var normalnum = 0; var warningnum = 0; var errornum = 0; @@ -922,21 +999,19 @@ function monitorStatAgg(type, inputarray){ var tempArray; var tempname; - switch(type){ + switch (type) { case 'blade': case 'cec': case 'rack': - case 'other': - { + case 'other': { tempArray = inputarray; } break; - case 'frame': - { + case 'frame': { tempArray = new Array(); for (var i in inputarray){ tempname = inputarray[i]; - for (var j in cechash[tempname]){ + for (var j in cechash[tempname]) { tempArray.push(cechash[tempname][j]); } } @@ -947,9 +1022,9 @@ function monitorStatAgg(type, inputarray){ break; } - for (var i in tempArray){ + for (var i in tempArray) { tempname = tempArray[i]; - switch(nodeStatus[tempname]){ + switch(nodeStatus[tempname]) { case 'NORMAL': normalnum++; break; @@ -978,7 +1053,7 @@ function monitorStatAgg(type, inputarray){ * * @return Nothing */ -function updateGangliaPage(){ +function updateGangliaPage() { if ($('#gangliaNodes').size() < 1) { return; } @@ -989,98 +1064,14 @@ function updateGangliaPage(){ gangliaTimer = window.setTimeout('updateGangliaPage()', 60000); } -/** - * extract the location query data, saved in global varible. - * - * @return Nothing - */ -function extractLocationlData(locationData){ - framehash = new Object(); - cechash = new Object(); - bladehash = new Object(); - rackhash = new Object(); - //other unknown nodes only have one parent, use number 1 as there parent - otherhash = new Object(); - otherhash[1] = new Array(); - - var allnodearray = locationData.split(';'); - var temparray; - var parent = ''; - var name = ''; - for(var i in allnodearray){ - temparray = allnodearray[i].split(':'); - name = temparray[0]; - //there is not parent(or mpa, or rack) information, jump this node - parent = temparray[2]; - if (!parent){ - continue; - } - switch(temparray[1].toLowerCase()){ - case 'blade': - { - if (!bladehash[parent]){ - bladehash[parent] = new Array(); - } - - bladehash[parent].push(name); - } - break; - - case 'systemx': - { - if (!rackhash[parent]){ - rackhash[parent] = new Array(); - } - rackhash[parent].push(name); - } - break; - - case 'frame': - { - if (!framehash[name]) - { - framehash[name] = new Array(); - } - } - break; - - case 'cec': - { - if (!framehash[parent]){ - framehash[parent] = new Array(); - } - framehash[parent].push(name); - } - break; - - case 'lpar': - case 'lpar,osi': - case 'osi,lpar': - { - if (!cechash[parent]){ - cechash[parent] = new Array(); - } - cechash[parent].push(name); - } - break; - default: - { - otherhash[1].push(name); - } - break; - } - } -} - /** * change the zoom area when click the zoom button * * @return Nothing */ -function updateZoom(obj){ +function updateZoom(obj) { var type=$(obj).attr('name'); - //delete all next cusion - while($('#zoomDiv span:last').attr('name') != type){ + while ($('#zoomDiv span:last').attr('name') != type) { $('#zoomDiv span:last').remove(); } $(obj).removeClass('monitorzoomlinkli'); @@ -1094,13 +1085,13 @@ function updateZoom(obj){ * * @return Nothing */ -function addZoomDiv(obj){ +function addZoomDiv(obj) { var name = $(obj).text(); var type = $(obj).attr('name'); var lastzoomobj = $('#zoomDiv span:last'); lastzoomobj.addClass('monitorzoomlink'); - lastzoomobj.bind('click', function(){ + lastzoomobj.bind('click', function() { updateZoom(this); }); diff --git a/xCAT-UI/xcat/plugins/web.pm b/xCAT-UI/xcat/plugins/web.pm index 16a7705bf..cbe8cb2f5 100644 --- a/xCAT-UI/xcat/plugins/web.pm +++ b/xCAT-UI/xcat/plugins/web.pm @@ -2186,7 +2186,7 @@ sub web_graphinfo{ } foreach(@missinfoarray){ - $missretstr = $missretstr . $_ . ':miss;'; + $missretstr = $missretstr . $_ . ':linux:other;'; } #combine all information into a string