diff --git a/xCAT-UI/ganglianode.php b/xCAT-UI/ganglianode.php index f9907ca82..a46f6151e 100644 --- a/xCAT-UI/ganglianode.php +++ b/xCAT-UI/ganglianode.php @@ -60,6 +60,8 @@ function drawNodesummary(summaryString){ drawLoadFlot('ganglianodeload', nodename, nodeData['load_one'], nodeData['cpu_num']); drawCpuFlot('ganglianodecpu', nodename, nodeData['cpu_idle']); drawMemFlot('ganglianodemem', nodename, nodeData['mem_free'], nodeData['mem_total']); + drawDiskFlot('ganglianodedisk', nodename, nodeData['disk_free'], nodeData['disk_total']); + drawNetworkFlot('ganglianodenetwork', nodename, nodeData['bytes_in'], nodeData['bytes_out']); }
+ +
+
+ + diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js index 69795cdfd..2ffc87373 100644 --- a/xCAT-UI/js/monitor/gangliamon.js +++ b/xCAT-UI/js/monitor/gangliamon.js @@ -157,10 +157,11 @@ function checkGangliaRunning(data){ var helpStr = '
aaa
'; //pass checking - var showStr = '

Grid Overview


' + + var showStr = '

Grid Overview

' + + '[Hide]
' + '
' + '

Nodes Current Status

' + - ' ?' + + ' ?' + '
Nodes in Group:' + groupsSelectStr + ' order by: ' + @@ -194,7 +195,7 @@ function checkGangliaRunning(data){ }); //bind the info click enent - $('#gangliamon sup').bind('click', function(){ + $('#gangliamon #nodehelp').bind('click', function(){ var helpStr = '' + '' + '' + @@ -215,6 +216,19 @@ function checkGangliaRunning(data){ } }); }); + + //bind the hide/show buttion event + $('#gangliamon #hidesup').bind('click', function(){ + var a = $(this).text(); + if ('[Hide]' == $(this).text()){ + $(this).html('[Show]'); + } + else{ + $(this).html('[Hide]'); + } + + $('#gangliaGridSummary').toggle(); + }); } /** @@ -370,14 +384,23 @@ function drawGridSummary() { if (-1 != tempStr.indexOf('hide')){ return; }; + + if ('[Show]' == $('#gangliamon #hidesup').text()){ + return; + } gridDrawArea.empty(); showStr = '
Normal
Heavy Load
' + '' + - '
'; + '
' + + '
' + + '
' + + ''; gridDrawArea.append(showStr); drawLoadFlot('gangliasummaryload', 'Grid', gridData['load_one'], gridData['cpu_num']); drawCpuFlot('gangliasummarycpu', 'Grid', gridData['cpu_idle']); drawMemFlot('gangliasummarymem', 'Grid', gridData['mem_free'], gridData['mem_total']); + drawDiskFlot('gangliasummarydisk', 'Grid', gridData['disk_free'], gridData['disk_total']); + drawNetworkFlot('gangliasummarynetwork', 'Grid', gridData['bytes_in'], gridData['bytes_out']); } /** @@ -548,6 +571,134 @@ function drawMemFlot(areaid, titleprefix, freepair, totalpair){ ); } +/** + * draw the disk usage flot by data(maybe 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 + * + * @return Nothing + */ +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){ + tempsize = freepair.length; + } + else{ + tempsize = freepair.length; + } + + 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],{ + title: titleprefix + ' Disk Use Last Hour', + axes:{ + xaxis:{ + renderer : $.jqplot.DateAxisRenderer, + numberTicks: 4, + tickOptions : { + formatString : '%R', + show : true + } + }, + yaxis: { + min : 0, + tickOptions:{formatString : '%.2fG'} + } + }, + legend : { + show: true, + location: 'nw' + }, + series:[{label:'Used'}, {label: 'Total'}], + seriesDefaults : {showMarker: false} + } + ); +} + +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){ + maxvalue = inpair[index + 1]; + } + } + + templength = outpair.length; + for (index = 0; index < templength; index += 2){ + if (outpair[index + 1] > maxvalue){ + maxvalue = outpair[index + 1]; + } + } + + if (maxvalue > 3000000){ + divisor = 1000000; + unitname = 'GB'; + } + else if(maxvalue >= 3000){ + divisor = 1000; + unitname = 'MB'; + } + else{ + //do nothing + } + + templength = inpair.length; + for (index = 0; index < templength; index += 2){ + inArray.push([(inpair[index] * 1000), (inpair[index + 1] / divisor)]); + } + + templength = outpair.length; + for (index = 0; index < templength; index += 2){ + outArray.push([(outpair[index] * 1000), (outpair[index + 1] / divisor)]); + } + + $.jqplot(areaid, [inArray, outArray],{ + title: titleprefix + ' Network Last Hour', + axes:{ + xaxis:{ + renderer : $.jqplot.DateAxisRenderer, + numberTicks: 4, + tickOptions : { + formatString : '%R', + show : true + } + }, + yaxis: { + min : 0, + tickOptions:{formatString : '%d' + unitname} + } + }, + legend : { + show: true, + location: 'nw' + }, + series:[{label:'In'}, {label: 'Out'}], + seriesDefaults : {showMarker: false} + } + ); +} + function createNodeStatusData(nodesStatus){ var index; var nodesArray = nodesStatus.split(';'); @@ -659,7 +810,7 @@ function drawGangliaNodesArea(ordertype){ $('.monitornormal,.monitorwarning').bind('click', function(){ var nodename = $(this).attr('title'); window.open('ganglianode.php?n=' + nodename + '&p=' + nodePath[nodename], - 'nodedetail','height=250,width=950,scrollbars=yes,status =no'); + 'nodedetail','height=430,width=950,scrollbars=yes,status =no'); }); } diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index 027ba6b4d..f184a1369 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -623,7 +623,7 @@ sub web_gangliaShow{ } if ('_summary_' eq $metric){ - my @metricArray = ('load_one', 'cpu_num', 'cpu_idle', 'mem_free', 'mem_total',); + my @metricArray = ('load_one', 'cpu_num', 'cpu_idle', 'mem_free', 'mem_total', 'disk_total', 'disk_free', 'bytes_in', 'bytes_out'); my $filename = ''; my $step = 1; my $index = 0; @@ -753,24 +753,19 @@ sub web_gangliaGridLatest{ my $callback = shift; my $retStr = ''; my $timestamp = time(); - if ($gangliaHash{'load_one'}){ - $retStr .= 'load_one:' . $timestamp . ',' . $gangliaHash{'load_one'}->{'SUM'} . ';'; - } - if ($gangliaHash{'cpu_num'}){ - $retStr .= 'cpu_num:' . $timestamp . ',' . $gangliaHash{'cpu_num'}->{'SUM'} . ';'; - } + my $metricname = ''; + my @metricArray = ('load_one', 'cpu_num', 'mem_total', 'mem_free', 'disk_total', 'disk_free', 'bytes_in', 'bytes_out'); + if ($gangliaHash{'cpu_idle'}){ my $sum = $gangliaHash{'cpu_idle'}->{'SUM'}; my $num = $gangliaHash{'cpu_idle'}->{'NUM'}; $retStr .= 'cpu_idle:' . $timestamp . ',' . (sprintf("%.2f", $sum/$num )) . ';'; } - if ($gangliaHash{'mem_total'}){ - $retStr .= 'mem_total:' . $timestamp . ',' . $gangliaHash{'mem_total'}->{'SUM'} . ';'; + foreach $metricname (@metricArray){ + if ($gangliaHash{$metricname}){ + $retStr .= $metricname . ':' . $timestamp . ',' . $gangliaHash{$metricname}->{'SUM'} . ';'; + } } - if ($gangliaHash{'mem_free'}){ - $retStr .= 'mem_free:' . $timestamp . ',' . $gangliaHash{'mem_free'}->{'SUM'} . ';'; - } - $retStr = substr($retStr, 0, -1); $callback->({data=>$retStr}); }