show disk and network metric on ganglia page
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10268 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
df84c5da02
commit
4147b86bef
@ -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']);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
@ -75,6 +77,11 @@ echo <<<EEE
|
||||
<td style="padding:0;border-style:none;"><div id="ganglianodecpu" class="monitorsumdiv"></div></td>
|
||||
<td style="padding:0;border-style: none;"><div id="ganglianodemem" class="monitorsumdiv"></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0;border-style:none;"><div id="ganglianodedisk" class="monitorsumdiv"></div></td>
|
||||
<td style="padding:0;border-style:none;"><div id="ganglianodenetwork" class="monitorsumdiv"></div></td>
|
||||
<td style="padding:0;border-style:none;"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -157,10 +157,11 @@ function checkGangliaRunning(data){
|
||||
var helpStr = '<div class="tooltip">aaa</div>';
|
||||
|
||||
//pass checking
|
||||
var showStr = '<h3>Grid Overview</h3><hr>' +
|
||||
var showStr = '<h3 style="display:inline;">Grid Overview</h3>' +
|
||||
'<sup id="hidesup" style="cursor: pointer;color:blue">[Hide]</sup><hr>' +
|
||||
'<div id="gangliaGridSummary"></div>' +
|
||||
'<h3 style="display:inline;">Nodes Current Status</h3>' +
|
||||
'<sup style="cursor: pointer;color:blue"> ?</sup>' +
|
||||
'<sup id="nodehelp" style="cursor: pointer;color:blue"> ?</sup>' +
|
||||
'<hr>Nodes in Group:' + groupsSelectStr +
|
||||
' order by: <select id="gangliaorder" style="padding:0px;"><option value="name">Name</option>' +
|
||||
'<option value="asc">Ascending</option><option value="des">Descending</option></select>' +
|
||||
@ -194,7 +195,7 @@ function checkGangliaRunning(data){
|
||||
});
|
||||
|
||||
//bind the info click enent
|
||||
$('#gangliamon sup').bind('click', function(){
|
||||
$('#gangliamon #nodehelp').bind('click', function(){
|
||||
var helpStr = '<table>' +
|
||||
'<tr><td style="background:#66CD00;" width="16px"> </td><td>Normal</td></tr>' +
|
||||
'<tr><td style="background:#FFD700;" width="16px"> </td><td>Heavy Load</td></tr>' +
|
||||
@ -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 = '<table style="border-style:none;"><tr><td style="padding:0;border-style:none;"><div id="gangliasummaryload" class="monitorsumdiv"></div></td>' +
|
||||
'<td style="padding:0;border-style:none;"><div id="gangliasummarycpu" class="monitorsumdiv"></div></td>' +
|
||||
'<td style="padding:0;border-style: none;"><div id="gangliasummarymem" class="monitorsumdiv"></div></td></tr></table>';
|
||||
'<td style="padding:0;border-style:none;"><div id="gangliasummarymem" class="monitorsumdiv"></div></td></tr>' +
|
||||
'<tr><td style="padding:0;border-style:none;"><div id="gangliasummarydisk" class="monitorsumdiv"></div></td>' +
|
||||
'<td style="padding:0;border-style:none;"><div id="gangliasummarynetwork" class="monitorsumdiv"></div></td>' +
|
||||
'<td style="padding:0;border-style:none;"></td></tr></table>';
|
||||
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');
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -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});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user