function loadGangliaMon(){ var gangMonTab = $('#gangliamon'); var gangMonStatus = createStatusBar('gangMonStatus'); gangMonTab.append(gangMonStatus); gangMonTab.append("
"); $('#gangMonConfig').hide(); addCfgButton(); gangMonTab.append(""); $('#gangLink').hide(); addGangLink(); $.ajax( { url : 'lib/systemcmd.php', dataType : 'json', data : { cmd : 'rpm -q rrdtool ganglia-gmetad ganglia-gmond ganglia-web' }, success : gangRpmCheck }); } function addCfgButton(){ var startButton = createButton('Start'); $('#gangMonConfig').append(startButton); startButton.bind('click', function(){ $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'gangliaStart', msg : '' }, success : function(data){ $('#rmcMonStatus').empty().append(data.rsp[0]); $('#gangLink').show(); } }); }); $('#gangMonConfig').append(startButton); var stopButton = createButton('Stop'); $('#gangMonConfig').append(startButton); stopButton.bind('click', function(){ $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'rmcstop', tgt : '', args : 'gangliamon,-r', msg : '' }, success : function(data){ $('#rmcMonStatus').empty().append(data.rsp[0]); $('#gangLink').hide(); } }); }); $('#gangMonConfig').append(stopButton); } function addGangLink(){ $('#gangLink').append('The Ganglia is running now. '); $('#gangLink').append('please click here to open the Ganglia\'s main page'); $('#gangLink a').click(function(){ window.open('../ganglia/'); }); } function gangRpmCheck(data){ var rpmStatus = data.rsp.split(/\n/); var stopFlag = false; var showString = ""; var tempArray = ["rrdtool", "ganglia-gmetad", "ganglia-gmond", "ganglia-web"]; for (var temp in rpmStatus){ if(-1 != rpmStatus[temp].indexOf("not")){ stopFlag = true; showString += "Please install " + tempArray[temp] + ".
"; } } if (stopFlag){ showString += "

References: xCAT2-Monitoring.pdf.

"; $('#gangMonStatus').empty().append(showString); return; } $('#gangMonConfig').show(); $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'monls', tgt : '', args : 'gangliamon', msg : '' }, success : function(data){ if (-1 != data.rsp[0].indexOf("not-monitored")){ $('#gangMonStatus').empty().append("Please start the Ganglia Monitoring first."); return; } $('#gangLink').show(); } }); }