2011-01-13 23:06:31 +00:00
|
|
|
/**
|
|
|
|
* Global variables
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// Save grid summary data, update every one minute
|
2011-08-09 09:10:51 +00:00
|
|
|
var gridData;
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Save nodes path, used for getting detail from rrd file
|
2011-08-09 09:10:51 +00:00
|
|
|
var nodePath = new Object();
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Save nodes current status,
|
|
|
|
// unknown = -2, error = -1, warning = 0 ,normal = 1 are used for sorting
|
2011-08-09 09:10:51 +00:00
|
|
|
var nodeStatus = new Object();
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Update timer
|
2011-08-09 09:10:51 +00:00
|
|
|
var gangliaTimer;
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Global frame hash
|
2011-12-07 08:09:16 +00:00
|
|
|
var framehash;
|
2012-02-08 15:49:36 +00:00
|
|
|
// Global cec hash
|
2011-12-07 08:09:16 +00:00
|
|
|
var cechash;
|
2012-02-08 15:49:36 +00:00
|
|
|
// Global blade hash
|
2011-12-07 08:09:16 +00:00
|
|
|
var bladehash;
|
2012-02-08 15:49:36 +00:00
|
|
|
// Global x rack hash
|
2011-12-07 08:09:16 +00:00
|
|
|
var rackhash;
|
2012-02-08 15:49:36 +00:00
|
|
|
// Global other type node hash
|
2011-12-31 08:43:58 +00:00
|
|
|
var otherhash;
|
2012-02-08 15:49:36 +00:00
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
/**
|
|
|
|
* Load Ganglia monitoring tool
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function loadGangliaMon() {
|
2011-09-12 16:10:53 +00:00
|
|
|
$('#gangliamon').append(createInfoBar('Checking RPMs'));
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get groups and set cookie
|
2011-09-12 16:10:53 +00:00
|
|
|
if (!$.cookie('groups')) {
|
2011-08-09 09:10:51 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'extnoderange',
|
|
|
|
tgt : '/.*',
|
|
|
|
args : 'subgroups',
|
|
|
|
msg : ''
|
|
|
|
},
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
success : setGroupsCookies
|
|
|
|
});
|
|
|
|
}
|
2012-02-08 15:49:36 +00:00
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
// Check whether Ganglia RPMs are installed on the xCAT MN
|
2011-01-14 05:05:06 +00:00
|
|
|
$.ajax({
|
2010-09-17 08:39:17 +00:00
|
|
|
url : 'lib/systemcmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
2011-08-09 09:10:51 +00:00
|
|
|
cmd : 'rpm -q rrdtool ganglia-gmetad ganglia-gmond'
|
2010-09-17 08:39:17 +00:00
|
|
|
},
|
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
success : checkGangliaRPMs
|
2010-09-17 08:39:17 +00:00
|
|
|
});
|
2010-11-05 22:53:47 +00:00
|
|
|
return;
|
2010-09-17 08:39:17 +00:00
|
|
|
}
|
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
/**
|
|
|
|
* Check whether Ganglia RPMs are installed
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function checkGangliaRPMs(data) {
|
|
|
|
var gangliaTab = $('#gangliamon');
|
2011-08-09 09:10:51 +00:00
|
|
|
gangliaTab.empty();
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
// Get the list of Ganglia RPMs installed
|
|
|
|
var status = data.rsp.split(/\n/);
|
2012-02-08 15:49:36 +00:00
|
|
|
var gangliaRPMs = ["rrdtool", "ganglia-gmetad", "ganglia-gmond"];
|
2010-11-05 22:53:47 +00:00
|
|
|
var warningMsg = 'Before continuing, please install the following packages: ';
|
|
|
|
var missingRPMs = false;
|
2011-09-12 16:10:53 +00:00
|
|
|
for (var i in status) {
|
2010-11-05 22:53:47 +00:00
|
|
|
if (status[i].indexOf("not installed") > -1) {
|
|
|
|
warningMsg += gangliaRPMs[i] + ' ';
|
|
|
|
missingRPMs = true;
|
|
|
|
}
|
|
|
|
}
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
// Append Ganglia PDF
|
|
|
|
if (missingRPMs) {
|
|
|
|
var warningBar = createWarnBar(warningMsg);
|
|
|
|
warningBar.css('margin-bottom', '10px');
|
|
|
|
warningBar.prependTo(gangliaTab);
|
2010-11-06 00:15:13 +00:00
|
|
|
} else {
|
2011-09-12 16:10:53 +00:00
|
|
|
gangliaTab.append(createInfoBar('Checking running status'));
|
|
|
|
|
|
|
|
// Check if ganglia is running on the xCAT MN
|
2010-11-06 00:15:13 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'monls',
|
|
|
|
tgt : '',
|
|
|
|
args : 'gangliamon',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
success : checkGangliaRunning
|
2010-11-17 18:53:40 +00:00
|
|
|
});
|
2010-11-06 00:15:13 +00:00
|
|
|
}
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-08-09 09:10:51 +00:00
|
|
|
* Check whether Ganglia is running
|
2010-11-05 22:53:47 +00:00
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
2011-08-09 09:10:51 +00:00
|
|
|
* @return Nothing
|
2010-11-05 22:53:47 +00:00
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function checkGangliaRunning(data) {
|
2011-08-09 09:10:51 +00:00
|
|
|
var gangliaTab = $('#gangliamon');
|
|
|
|
gangliaTab.empty();
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// If Ganglia is not started
|
2011-08-09 09:10:51 +00:00
|
|
|
if (data.rsp[0].indexOf("not-monitored") > -1) {
|
|
|
|
// Create link to start Ganglia
|
|
|
|
var startLnk = $('<a href="#">Click here</a>');
|
2012-02-08 15:49:36 +00:00
|
|
|
startLnk.css({
|
2011-08-09 09:10:51 +00:00
|
|
|
'color' : 'blue',
|
|
|
|
'text-decoration' : 'none'
|
|
|
|
});
|
|
|
|
startLnk.click(function() {
|
|
|
|
// Turn on Ganglia for all nodes
|
|
|
|
monitorNode('', 'on');
|
|
|
|
});
|
2010-11-05 22:53:47 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
// Create warning bar
|
|
|
|
var warningBar = $('<div class="ui-state-error ui-corner-all"></div>');
|
2011-08-24 19:28:24 +00:00
|
|
|
var msg = $('<p></p>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
var icon = $('<span class="ui-icon ui-icon-alert"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
warningBar.append(icon);
|
|
|
|
msg.append('Please start Ganglia on xCAT. ');
|
2011-08-09 09:10:51 +00:00
|
|
|
msg.append(startLnk);
|
2011-08-24 19:28:24 +00:00
|
|
|
msg.append(' to start Ganglia.');
|
2011-08-09 09:10:51 +00:00
|
|
|
warningBar.append(msg);
|
|
|
|
warningBar.css('margin-bottom', '10px');
|
2010-11-05 22:53:47 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
// If there are any warning messages, append this warning after it
|
|
|
|
var curWarnings = $('#gangliamon').find('.ui-state-error');
|
|
|
|
|
|
|
|
if (curWarnings.length) {
|
|
|
|
curWarnings.after(warningBar);
|
|
|
|
} else {
|
|
|
|
warningBar.prependTo(gangliaTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2011-01-14 05:05:06 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Legend for node status
|
|
|
|
var legend = '<table style="float:right"><tr>' +
|
|
|
|
'<td style="background:#66CD00;width:16px;padding:0px;"> </td><td style="padding:0px;border:0px">Normal</td>' +
|
|
|
|
'<td style="background:#FFD700;width:16px;padding:0px;"> </td><td style="padding:0px;">Heavy Load</td>' +
|
|
|
|
'<td style="background:#FF3030;width:16px;padding:0px;"> </td><td style="padding:0px;">Error</td>' +
|
|
|
|
'<td style="background:#8B8B7A;width:16px;padding:0px;"> </td><td style="padding:0px;">Unknown</td>' +
|
|
|
|
'</tr></table>';
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Gganglia grid overview
|
2011-08-19 07:31:20 +00:00
|
|
|
var showStr = '<div><h3 style="display:inline;">Grid Overview</h3>' +
|
|
|
|
'<sup id="hidesup" style="cursor: pointer;color:blue;float:right">[Hide]</sup></div><hr>' +
|
2011-08-09 09:10:51 +00:00
|
|
|
'<div id="gangliaGridSummary"></div>' +
|
2012-02-08 15:49:36 +00:00
|
|
|
'<div><h3 style="display:inline;">Current Nodes Status</h3>' + legend + '</div><hr>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
'<div id="zoomDiv" style="padding:0px 0px 12px 0px;"><span name="ALL">All Nodes</span></div>' +
|
2011-08-09 09:10:51 +00:00
|
|
|
'<div id="gangliaNodes"></div>';
|
|
|
|
gangliaTab.append(showStr);
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get summary data and draw on page
|
2011-09-12 16:10:53 +00:00
|
|
|
$('#gangliaGridSummary').append('Getting grid summary data <img src="images/loader.gif"></img>');
|
2011-08-09 09:10:51 +00:00
|
|
|
sendGridSummaryAjax();
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get all nodes location data which can support the zoom monitor
|
2011-12-07 08:09:16 +00:00
|
|
|
$('#gangliaNodes').append('Getting all nodes status <img src="images/loader.gif"></img>');
|
|
|
|
sendLocationAjax();
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Bind the hide/show button event
|
2011-08-11 09:42:23 +00:00
|
|
|
$('#gangliamon #hidesup').bind('click', function(){
|
2012-02-08 15:49:36 +00:00
|
|
|
if ('[Hide]' == $(this).text()) {
|
2011-08-11 09:42:23 +00:00
|
|
|
$(this).html('[Show]');
|
2012-02-08 15:49:36 +00:00
|
|
|
} else {
|
2011-08-11 09:42:23 +00:00
|
|
|
$(this).html('[Hide]');
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#gangliaGridSummary').toggle();
|
|
|
|
});
|
2010-09-17 08:39:17 +00:00
|
|
|
}
|
2010-09-24 02:27:04 +00:00
|
|
|
|
2011-12-07 08:09:16 +00:00
|
|
|
/**
|
2012-02-08 15:49:36 +00:00
|
|
|
* Send AJAX request to get all nodes parent and position to create hardware hierarchy hash
|
2011-12-07 08:09:16 +00:00
|
|
|
*
|
2012-02-08 15:49:36 +00:00
|
|
|
* @return Nothing
|
2011-12-07 08:09:16 +00:00
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function sendLocationAjax() {
|
2011-12-07 08:09:16 +00:00
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'graph',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success: function(data){
|
2012-02-08 15:49:36 +00:00
|
|
|
if (!data.rsp[0]) {
|
2011-12-07 08:09:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-02-08 15:49:36 +00:00
|
|
|
|
2011-12-07 08:09:16 +00:00
|
|
|
extractLocationlData(data.rsp[0]);
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get nodes current status and draw on the page
|
2011-12-07 08:09:16 +00:00
|
|
|
sendNodeCurrentAjax();
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Start the timer to update page per minute
|
2011-12-07 08:09:16 +00:00
|
|
|
gangliaTimer = window.setTimeout('updateGangliaPage()', 60000);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-05 22:53:47 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Send AJAX request to get grid summary information
|
|
|
|
*
|
2010-11-05 22:53:47 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function sendGridSummaryAjax() {
|
|
|
|
// Get the summary data
|
2011-08-09 09:10:51 +00:00
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'gangliashow;_grid_;hour;_summary_',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
success: function(data) {
|
2011-08-09 09:10:51 +00:00
|
|
|
createGridSummaryData(data.rsp[0]);
|
|
|
|
drawGridSummary();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-11-05 22:53:47 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Send AJAX request to get nodes current load information
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function sendNodeCurrentAjax() {
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get all nodes current status
|
2011-08-09 09:10:51 +00:00
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
2011-12-07 08:09:16 +00:00
|
|
|
args : 'gangliacurrent;node;',
|
2011-08-09 09:10:51 +00:00
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success: function(data){
|
|
|
|
createNodeStatusData(data.rsp[0]);
|
|
|
|
drawGangliaNodesArea($('#gangliaorder').val());
|
|
|
|
}
|
|
|
|
});
|
2010-11-05 22:53:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-08 15:49:36 +00:00
|
|
|
* Send AJAX request to get grid current summary information to update the page
|
2011-09-12 16:10:53 +00:00
|
|
|
*
|
2011-08-09 09:10:51 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function sendGridCurrentAjax(){
|
2012-02-08 15:49:36 +00:00
|
|
|
// Get the summary data
|
2011-08-09 09:10:51 +00:00
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'gangliacurrent;grid',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success: function(data){
|
|
|
|
updateGridSummaryData(data.rsp[0]);
|
|
|
|
drawGridSummary();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Save the grid summary data to local global variable
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
|
|
|
* @param data structure
|
|
|
|
* metric1:time11,val11,time12,val12....;metric2:time21,val21,time22,val22,...;....
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function createGridSummaryData(summaryString){
|
2012-02-08 15:49:36 +00:00
|
|
|
// Empty the global data
|
2011-08-09 09:10:51 +00:00
|
|
|
gridData = new Object();
|
|
|
|
|
|
|
|
var metricArray = summaryString.split(';');
|
|
|
|
var metricname = '';
|
|
|
|
var valueArray = '';
|
|
|
|
var position = 0;
|
|
|
|
var tempLength = 0;
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var index = 0; index < metricArray.length; index++) {
|
2011-08-09 09:10:51 +00:00
|
|
|
position = metricArray[index].indexOf(':');
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// Get the metric name and init its global array to save timestamp and value pair
|
2011-08-09 09:10:51 +00:00
|
|
|
metricname = metricArray[index].substr(0, position);
|
|
|
|
gridData[metricname] = new Array();
|
|
|
|
valueArray = metricArray[index].substr(position + 1).split(',');
|
|
|
|
tempLength = valueArray.length;
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// Save timestamp and value into global array
|
|
|
|
for (var i = 0; i < tempLength; i++) {
|
2011-08-09 09:10:51 +00:00
|
|
|
gridData[metricname].push(Number(valueArray[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Update the grid summary data to local global variable
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
|
|
|
* @param data structure
|
|
|
|
* metric1:time11,val11;metric2:time21,val21,time22;....
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function updateGridSummaryData(currentString){
|
|
|
|
var metricArray = currentString.split(';');
|
|
|
|
var metricname = '';
|
|
|
|
var position = 0;
|
|
|
|
var tempLength = 0;
|
|
|
|
var index = 0;
|
|
|
|
var tempArray;
|
|
|
|
|
|
|
|
tempLength = metricArray.length;
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < tempLength; index++) {
|
2011-08-09 09:10:51 +00:00
|
|
|
position = metricArray[index].indexOf(':');
|
|
|
|
metricname = metricArray[index].substr(0, position);
|
|
|
|
tempArray = metricArray[index].substr(position + 1).split(',');
|
2011-09-12 16:10:53 +00:00
|
|
|
if (gridData[metricname]) {
|
2011-08-09 09:10:51 +00:00
|
|
|
gridData[metricname].shift();
|
|
|
|
gridData[metricname].shift();
|
|
|
|
gridData[metricname].push(Number(tempArray[0]));
|
|
|
|
gridData[metricname].push(Number(tempArray[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-08 15:49:36 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw the grid summay area by global data
|
2010-11-05 22:53:47 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2011-08-09 09:10:51 +00:00
|
|
|
function drawGridSummary() {
|
|
|
|
var gridDrawArea = $('#gangliaGridSummary');
|
|
|
|
var showStr = '';
|
|
|
|
var tempStr = $('#gangliamon').attr('class');
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// jqflot only draws on the visible area
|
|
|
|
// If the tab is hide, return directly
|
|
|
|
if (tempStr.indexOf('hide') != -1) {
|
2011-08-09 09:10:51 +00:00
|
|
|
return;
|
2011-09-12 16:10:53 +00:00
|
|
|
}
|
2011-08-11 09:42:23 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
if ($('#gangliamon #hidesup').text() == '[Show]') {
|
2011-08-11 09:42:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
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>' +
|
2011-08-11 09:42:23 +00:00
|
|
|
'<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>';
|
2011-08-09 09:10:51 +00:00
|
|
|
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']);
|
2011-08-11 09:42:23 +00:00
|
|
|
drawDiskFlot('gangliasummarydisk', 'Grid', gridData['disk_free'], gridData['disk_total']);
|
|
|
|
drawNetworkFlot('gangliasummarynetwork', 'Grid', gridData['bytes_in'], gridData['bytes_out']);
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
2010-11-05 22:53:47 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw the load flot by data(summary data, or one node's data)
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
2011-09-12 16:10:53 +00:00
|
|
|
* @param areaid
|
|
|
|
* Which DIV draw this flot
|
|
|
|
* @param loadpair
|
|
|
|
* The load timestamp and value pair
|
|
|
|
* @param cpupair
|
|
|
|
* The CPU number and value pair
|
2011-08-09 09:10:51 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawLoadFlot(areaid, titleprefix, loadpair, cpupair) {
|
2011-08-09 09:10:51 +00:00
|
|
|
var load = new Array();
|
|
|
|
var cpunum = new Array();
|
|
|
|
var index = 0;
|
|
|
|
var yaxismax = 0;
|
|
|
|
var interval = 1;
|
|
|
|
|
|
|
|
$('#' + areaid).empty();
|
2012-02-08 15:49:36 +00:00
|
|
|
// Parse load pair, the timestamp must mutiply 1000, javascript time stamp is millisecond
|
|
|
|
for (index = 0; index < loadpair.length; index += 2) {
|
2011-08-09 09:10:51 +00:00
|
|
|
load.push([loadpair[index] * 1000, loadpair[index + 1]]);
|
2012-02-08 15:49:36 +00:00
|
|
|
if (loadpair[index + 1] > yaxismax) {
|
2011-08-09 09:10:51 +00:00
|
|
|
yaxismax = loadpair[index + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Parse cpu pair
|
|
|
|
for (index = 0; index < cpupair.length; index += 2) {
|
2011-08-09 09:10:51 +00:00
|
|
|
cpunum.push([cpupair[index] * 1000, cpupair[index + 1]]);
|
2012-02-08 15:49:36 +00:00
|
|
|
if (cpupair[index + 1] > yaxismax) {
|
2011-08-09 09:10:51 +00:00
|
|
|
yaxismax = cpupair[index + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interval = parseInt(yaxismax / 3);
|
2012-02-08 15:49:36 +00:00
|
|
|
if (interval < 1) {
|
2011-08-09 09:10:51 +00:00
|
|
|
interval = 1;
|
|
|
|
}
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
$.jqplot(areaid, [load, cpunum], {
|
2011-08-09 09:10:51 +00:00
|
|
|
title: titleprefix + ' Loads/Procs Last Hour',
|
|
|
|
axes:{
|
|
|
|
xaxis:{
|
|
|
|
renderer : $.jqplot.DateAxisRenderer,
|
|
|
|
numberTicks: 4,
|
|
|
|
tickOptions : {
|
|
|
|
formatString : '%R',
|
|
|
|
show : true
|
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
},
|
2011-08-09 09:10:51 +00:00
|
|
|
yaxis: {
|
|
|
|
min : 0,
|
|
|
|
tickInterval : interval
|
2011-07-20 21:13:09 +00:00
|
|
|
}
|
2011-08-09 09:10:51 +00:00
|
|
|
},
|
|
|
|
legend : {
|
|
|
|
show: true,
|
|
|
|
location: 'nw'
|
|
|
|
},
|
|
|
|
series:[{label:'Load'}, {label: 'CPU Number'}],
|
|
|
|
seriesDefaults : {showMarker: false}
|
2012-02-08 15:49:36 +00:00
|
|
|
});
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw the CPU usage flot by data(maybe summary data, or one node's data)
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
2011-09-12 16:10:53 +00:00
|
|
|
* @param areaid
|
|
|
|
* Which DIV draw this flot
|
|
|
|
* @param titleprefix
|
|
|
|
* Title used name
|
|
|
|
* @param cpupair
|
|
|
|
* The CPU timestamp and value pair
|
2011-08-09 09:10:51 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawCpuFlot(areaid, titleprefix, cpupair) {
|
2011-08-09 09:10:51 +00:00
|
|
|
var cpu = new Array();
|
|
|
|
var index = 0;
|
|
|
|
|
|
|
|
$('#' + areaid).empty();
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Time stamp should be mutiplied by 1000
|
|
|
|
// We get the CPU idle from server
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < cpupair.length; index +=2) {
|
2011-08-09 09:10:51 +00:00
|
|
|
cpu.push([(cpupair[index] * 1000), (100 - cpupair[index + 1])]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$.jqplot(areaid, [cpu],{
|
|
|
|
title: titleprefix + ' Cpu Use Last Hour',
|
|
|
|
axes:{
|
|
|
|
xaxis:{
|
|
|
|
renderer : $.jqplot.DateAxisRenderer,
|
|
|
|
numberTicks: 4,
|
|
|
|
tickOptions : {
|
|
|
|
formatString : '%R',
|
|
|
|
show : true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
yaxis: {
|
|
|
|
min : 0,
|
|
|
|
max : 100,
|
|
|
|
tickOptions:{formatString : '%d\%'}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
seriesDefaults : {showMarker: false}
|
2012-02-08 15:49:36 +00:00
|
|
|
});
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw the memory usage flot by data(summary data, or one node's data)
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
2011-09-12 16:10:53 +00:00
|
|
|
* @param areaid
|
|
|
|
* Which DIV draw this flot
|
|
|
|
* @param titleprefix
|
|
|
|
* Title used name
|
|
|
|
* @param cpupair
|
|
|
|
* The CPU timestamp and value pair
|
2011-08-09 09:10:51 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function drawMemFlot(areaid, titleprefix, freepair, totalpair){
|
|
|
|
var use = new Array();
|
|
|
|
var total = new Array();
|
|
|
|
var tempsize = 0;
|
|
|
|
var index = 0;
|
|
|
|
|
|
|
|
$('#' + areaid).empty();
|
2011-09-12 16:10:53 +00:00
|
|
|
if (freepair.length < totalpair.length) {
|
2011-08-09 09:10:51 +00:00
|
|
|
tempsize = freepair.length;
|
2011-09-12 16:10:53 +00:00
|
|
|
} else {
|
2011-08-09 09:10:51 +00:00
|
|
|
tempsize = freepair.length;
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < tempsize; index += 2) {
|
2011-08-09 09:10:51 +00:00
|
|
|
var temptotal = totalpair[index + 1];
|
|
|
|
var tempuse = temptotal - freepair[index + 1];
|
|
|
|
temptotal = temptotal / 1000000;
|
|
|
|
tempuse = tempuse / 1000000;
|
|
|
|
total.push([totalpair[index] * 1000, temptotal]);
|
|
|
|
use.push([freepair[index] * 1000, tempuse]);
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
$.jqplot(areaid, [use, total], {
|
2011-08-09 09:10:51 +00:00
|
|
|
title: titleprefix + ' Memory 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}
|
2012-02-08 15:49:36 +00:00
|
|
|
});
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-08-11 09:42:23 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw the disk usage flot by data(summary data, or one node's data)
|
2011-08-11 09:42:23 +00:00
|
|
|
*
|
2011-09-12 16:10:53 +00:00
|
|
|
* @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
|
2011-08-11 09:42:23 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawDiskFlot(areaid, titleprefix, freepair, totalpair) {
|
2011-08-11 09:42:23 +00:00
|
|
|
var use = new Array();
|
|
|
|
var total = new Array();
|
|
|
|
var tempsize = 0;
|
|
|
|
var index = 0;
|
|
|
|
|
|
|
|
$('#' + areaid).empty();
|
2012-02-08 15:49:36 +00:00
|
|
|
if (freepair.length < totalpair.length) {
|
2011-08-11 09:42:23 +00:00
|
|
|
tempsize = freepair.length;
|
2012-02-08 15:49:36 +00:00
|
|
|
} else{
|
2011-08-11 09:42:23 +00:00
|
|
|
tempsize = freepair.length;
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
for (index = 0; index < tempsize; index += 2) {
|
2011-08-11 09:42:23 +00:00
|
|
|
var temptotal = totalpair[index + 1];
|
|
|
|
var tempuse = temptotal - freepair[index + 1];
|
|
|
|
total.push([totalpair[index] * 1000, temptotal]);
|
|
|
|
use.push([freepair[index] * 1000, tempuse]);
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
$.jqplot(areaid, [use, total], {
|
2011-08-11 09:42:23 +00:00
|
|
|
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}
|
2012-02-08 15:49:36 +00:00
|
|
|
});
|
2011-08-11 09:42:23 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawNetworkFlot(areaid, titleprefix, inpair, outpair) {
|
2011-08-11 09:42:23 +00:00
|
|
|
var inArray = new Array();
|
|
|
|
var outArray = new Array();
|
|
|
|
var index = 0;
|
|
|
|
var maxvalue = 0;
|
|
|
|
var unitname = 'B';
|
|
|
|
var divisor = 1;
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < inpair.length; index += 2) {
|
|
|
|
if (inpair[index + 1] > maxvalue) {
|
2011-08-11 09:42:23 +00:00
|
|
|
maxvalue = inpair[index + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < outpair.length; index += 2) {
|
|
|
|
if (outpair[index + 1] > maxvalue) {
|
2011-08-11 09:42:23 +00:00
|
|
|
maxvalue = outpair[index + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
if (maxvalue > 3000000) {
|
2011-08-11 09:42:23 +00:00
|
|
|
divisor = 1000000;
|
|
|
|
unitname = 'GB';
|
2011-09-12 16:10:53 +00:00
|
|
|
} else if (maxvalue >= 3000) {
|
2011-08-11 09:42:23 +00:00
|
|
|
divisor = 1000;
|
|
|
|
unitname = 'MB';
|
2011-09-12 16:10:53 +00:00
|
|
|
} else {
|
2011-08-11 09:42:23 +00:00
|
|
|
//do nothing
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < inpair.length; index += 2) {
|
2011-08-11 09:42:23 +00:00
|
|
|
inArray.push([(inpair[index] * 1000), (inpair[index + 1] / divisor)]);
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < outpair.length; index += 2) {
|
2011-08-11 09:42:23 +00:00
|
|
|
outArray.push([(outpair[index] * 1000), (outpair[index + 1] / divisor)]);
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
$.jqplot(areaid, [inArray, outArray], {
|
2011-08-11 09:42:23 +00:00
|
|
|
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}
|
2011-09-12 16:10:53 +00:00
|
|
|
});
|
2011-08-11 09:42:23 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
/**
|
|
|
|
* Create node status data
|
|
|
|
*
|
|
|
|
* @param nodesStatus
|
|
|
|
* Node status
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function createNodeStatusData(nodesStatus) {
|
2011-08-09 09:10:51 +00:00
|
|
|
var nodesArray = nodesStatus.split(';');
|
|
|
|
var position = 0;
|
|
|
|
var nodename = '';
|
|
|
|
var index = 0;
|
|
|
|
var tempArray;
|
|
|
|
var tempStr = '';
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index in nodePath) {
|
2011-08-09 09:10:51 +00:00
|
|
|
delete(nodePath[index]);
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index in nodeStatus) {
|
2011-08-09 09:10:51 +00:00
|
|
|
delete(nodeStatus[index]);
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < nodesArray.length; index++) {
|
2011-08-09 09:10:51 +00:00
|
|
|
tempStr = nodesArray[index];
|
|
|
|
position = tempStr.indexOf(':');
|
|
|
|
nodename = tempStr.substring(0, position);
|
|
|
|
tempArray = tempStr.substring(position + 1).split(',');
|
2011-12-07 08:09:16 +00:00
|
|
|
nodeStatus[nodename] = tempArray[0];
|
|
|
|
if (('WARNING' == tempArray[0]) || ('NORMAL' == tempArray[0])){
|
|
|
|
nodePath[nodename] = tempArray[1];
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2011-08-09 09:10:51 +00:00
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Draw nodes current status, there are four type:
|
2012-02-08 15:49:36 +00:00
|
|
|
* 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
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawGangliaNodesArea() {
|
2011-12-07 08:09:16 +00:00
|
|
|
var position = 0;
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// Find out the last child's type and name
|
2011-12-07 08:09:16 +00:00
|
|
|
var currentobj = $('#zoomDiv span:last');
|
|
|
|
var type = currentobj.attr('name').toLowerCase();
|
|
|
|
var name = currentobj.text();
|
|
|
|
position = name.indexOf('(');
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
if (position > -1) {
|
2011-12-07 08:09:16 +00:00
|
|
|
name = name.substr(3, position - 3);
|
|
|
|
}
|
|
|
|
$('#gangliaNodes').empty();
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
switch (type) {
|
|
|
|
// Draw the node current status
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'blade':
|
|
|
|
case 'cec':
|
|
|
|
case 'rack':
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'other': {
|
2011-12-07 08:09:16 +00:00
|
|
|
drawGangliaNodesAreaPic(type, name);
|
|
|
|
}
|
|
|
|
break;
|
2012-02-08 15:49:36 +00:00
|
|
|
|
|
|
|
// Draw a summary table
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'all':
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'frame': {
|
|
|
|
drawGangliaNodesAreaTable(type, name);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawGangliaNodesAreaPic(type, name) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var index = 0;
|
2012-02-08 15:49:36 +00:00
|
|
|
var arraypoint = '';
|
2011-08-09 09:10:51 +00:00
|
|
|
var templength = 0;
|
|
|
|
var showStr = '';
|
|
|
|
var nodename = '';
|
2011-09-12 16:10:53 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
switch(type) {
|
|
|
|
case 'blade': {
|
2011-12-07 08:09:16 +00:00
|
|
|
arraypoint = bladehash[name];
|
|
|
|
}
|
|
|
|
break;
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'cec': {
|
2011-12-07 08:09:16 +00:00
|
|
|
arraypoint = cechash[name];
|
|
|
|
}
|
|
|
|
break;
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'rack': {
|
2011-12-07 08:09:16 +00:00
|
|
|
arraypoint = rackhash[name];
|
|
|
|
}
|
|
|
|
break;
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'other': {
|
2011-12-31 08:43:58 +00:00
|
|
|
arraypoint = otherhash[1];
|
|
|
|
}
|
2011-12-07 08:09:16 +00:00
|
|
|
default:
|
|
|
|
break;
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
2011-12-07 08:09:16 +00:00
|
|
|
$('#gangliaNodes').html('<ul style="margin:0px;padding:0px;"></ul>');
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2011-12-07 08:09:16 +00:00
|
|
|
templength = arraypoint.length;
|
2011-08-09 09:10:51 +00:00
|
|
|
|
2011-09-12 16:10:53 +00:00
|
|
|
for (index = 0; index < templength; index++) {
|
2011-12-07 08:09:16 +00:00
|
|
|
nodename = arraypoint[index];
|
|
|
|
switch (nodeStatus[nodename]) {
|
|
|
|
case 'ERROR':
|
2011-09-12 16:10:53 +00:00
|
|
|
showStr = '<li class="monitorerror ui-corner-all monitornodeli" title="' + nodename + '"></li>';
|
|
|
|
break;
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'WARNING':
|
2011-09-12 16:10:53 +00:00
|
|
|
showStr = '<li class="mornitorwarning ui-corner-all monitornodeli" title="' + nodename + '"></li>';
|
|
|
|
break;
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'NORMAL':
|
2011-09-12 16:10:53 +00:00
|
|
|
showStr = '<li class="monitornormal ui-corner-all monitornodeli" title="' + nodename + '"></li>';
|
|
|
|
break;
|
2011-12-07 08:09:16 +00:00
|
|
|
default:
|
|
|
|
showStr = '<li class="monitorunknown ui-corner-all monitornodeli" title="' + nodename + '"></li>';
|
|
|
|
break;
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
$('#gangliaNodes ul').append(showStr);
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
// Bind all normal and warning nodes click event
|
2011-09-12 16:10:53 +00:00
|
|
|
$('.monitornormal,.monitorwarning').bind('click', function() {
|
2011-08-09 09:10:51 +00:00
|
|
|
var nodename = $(this).attr('title');
|
|
|
|
window.open('ganglianode.php?n=' + nodename + '&p=' + nodePath[nodename],
|
2011-08-11 09:42:23 +00:00
|
|
|
'nodedetail','height=430,width=950,scrollbars=yes,status =no');
|
2011-08-09 09:10:51 +00:00
|
|
|
});
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
function drawGangliaNodesAreaTable(type, name) {
|
|
|
|
var table = $('<table></table>');
|
|
|
|
var row = '';
|
|
|
|
var usedCec = new Object();
|
|
|
|
|
|
|
|
var header = $('<thead class="ui-widget-header"> <th>Name</th><th>Type</th><th>Normal</th><th>Heavy Load</th><th>Error</th><th>Unknown</th> </thead>');
|
|
|
|
table.append(header);
|
|
|
|
|
|
|
|
if (type == 'all') {
|
|
|
|
for (var i in framehash) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var framename = i;
|
2012-02-08 15:49:36 +00:00
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="frame">' + framename + '</a></td><td>Frame</td>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
monitorStatAgg('frame', framehash[i]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-07 08:09:16 +00:00
|
|
|
for(var j in framehash[i]){
|
2012-02-08 15:49:36 +00:00
|
|
|
usedCec[framehash[i][j]] = 1;
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var i in cechash) {
|
|
|
|
if (usedCec[i]) {
|
2011-12-07 08:09:16 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var cecname = i;
|
2012-02-08 15:49:36 +00:00
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="cec">' + cecname + '</a></td><td>CEC</td>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
monitorStatAgg('cec', cechash[i]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var i in bladehash) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var bladename = i;
|
2012-02-08 15:49:36 +00:00
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="blade">' + bladename + '</a></td><td>Blade</td>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
monitorStatAgg('blade', bladehash[i]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var i in rackhash) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var rackname = i;
|
2012-02-08 15:49:36 +00:00
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="rack">' + rackname + '</a></td><td>Rack</td>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
monitorStatAgg('rack', rackhash[i]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
2011-12-31 08:43:58 +00:00
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
if (otherhash[1].length > 0) {
|
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="other">Other</a></td><td>Other</td>' +
|
2011-12-31 08:43:58 +00:00
|
|
|
monitorStatAgg('other', otherhash[1]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-31 08:43:58 +00:00
|
|
|
}
|
2012-02-08 15:49:36 +00:00
|
|
|
} else {
|
|
|
|
for (var i in framehash[name]) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var cecname = framehash[name][i];
|
2012-02-08 15:49:36 +00:00
|
|
|
row = '<tr><td><a href="#" onclick="addZoomDiv(this)" name="cec">' + cecname + '</a></td>' +
|
2011-12-07 08:09:16 +00:00
|
|
|
'<td>CEC</td>' + monitorStatAgg('cec', cechash[cecname]) + '</tr>';
|
2012-02-08 15:49:36 +00:00
|
|
|
table.append(row);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
$('#gangliaNodes').append(table);
|
2011-12-07 08:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update all tab per minute.
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function monitorStatAgg(type, inputarray) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var normalnum = 0;
|
|
|
|
var warningnum = 0;
|
|
|
|
var errornum = 0;
|
|
|
|
var nuknownnum = 0;
|
|
|
|
var tempArray;
|
|
|
|
var tempname;
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
switch (type) {
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'blade':
|
|
|
|
case 'cec':
|
|
|
|
case 'rack':
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'other': {
|
2011-12-07 08:09:16 +00:00
|
|
|
tempArray = inputarray;
|
|
|
|
}
|
|
|
|
break;
|
2012-02-08 15:49:36 +00:00
|
|
|
case 'frame': {
|
2011-12-07 08:09:16 +00:00
|
|
|
tempArray = new Array();
|
|
|
|
for (var i in inputarray){
|
|
|
|
tempname = inputarray[i];
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var j in cechash[tempname]) {
|
2011-12-07 08:09:16 +00:00
|
|
|
tempArray.push(cechash[tempname][j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-08 15:49:36 +00:00
|
|
|
for (var i in tempArray) {
|
2011-12-07 08:09:16 +00:00
|
|
|
tempname = tempArray[i];
|
2012-02-08 15:49:36 +00:00
|
|
|
switch(nodeStatus[tempname]) {
|
2011-12-07 08:09:16 +00:00
|
|
|
case 'NORMAL':
|
|
|
|
normalnum++;
|
|
|
|
break;
|
|
|
|
case 'WARNING':
|
|
|
|
warningnum++;
|
|
|
|
break;
|
|
|
|
case 'ERROR':
|
|
|
|
errornum++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
nuknownnum++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
normalnum = normalnum?normalnum:'-';
|
|
|
|
warningnum = warningnum?warningnum:'-';
|
|
|
|
errornum = errornum?errornum:'-';
|
|
|
|
nuknownnum = nuknownnum?nuknownnum:'-';
|
|
|
|
|
|
|
|
return ('<td>' + normalnum + '</td><td>' + warningnum + '</td><td>' + errornum + '</td><td>' + nuknownnum + '</td>');
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-09-12 16:10:53 +00:00
|
|
|
* Update all tab per minute.
|
2011-08-09 09:10:51 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function updateGangliaPage() {
|
2011-09-12 16:10:53 +00:00
|
|
|
if ($('#gangliaNodes').size() < 1) {
|
2011-08-09 09:10:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sendGridCurrentAjax();
|
|
|
|
sendNodeCurrentAjax();
|
|
|
|
|
|
|
|
gangliaTimer = window.setTimeout('updateGangliaPage()', 60000);
|
|
|
|
}
|
|
|
|
|
2011-12-07 08:09:16 +00:00
|
|
|
/**
|
|
|
|
* change the zoom area when click the zoom button
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function updateZoom(obj) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var type=$(obj).attr('name');
|
2012-02-08 15:49:36 +00:00
|
|
|
while ($('#zoomDiv span:last').attr('name') != type) {
|
2011-12-07 08:09:16 +00:00
|
|
|
$('#zoomDiv span:last').remove();
|
|
|
|
}
|
|
|
|
$(obj).removeClass('monitorzoomlinkli');
|
|
|
|
$(obj).unbind('click');
|
|
|
|
|
|
|
|
drawGangliaNodesArea();
|
2011-08-09 09:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-12-07 08:09:16 +00:00
|
|
|
/**
|
|
|
|
* add the zoom level when click the group link in the summary table
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2012-02-08 15:49:36 +00:00
|
|
|
function addZoomDiv(obj) {
|
2011-12-07 08:09:16 +00:00
|
|
|
var name = $(obj).text();
|
|
|
|
var type = $(obj).attr('name');
|
|
|
|
|
|
|
|
var lastzoomobj = $('#zoomDiv span:last');
|
2011-12-07 09:16:21 +00:00
|
|
|
lastzoomobj.addClass('monitorzoomlink');
|
2012-02-08 15:49:36 +00:00
|
|
|
lastzoomobj.bind('click', function() {
|
2011-12-07 08:09:16 +00:00
|
|
|
updateZoom(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
var newcontent = ' > ' + name + '(' + type.toUpperCase() + ')';
|
|
|
|
var newli = '<span name="' + type + '">' + newcontent + '</span>';
|
|
|
|
$('#zoomDiv').append(newli);
|
|
|
|
|
|
|
|
drawGangliaNodesArea();
|
2010-09-17 08:39:17 +00:00
|
|
|
}
|