From 1d18c1455122fc4a2d8eeab7427942558ecc3cf5 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Fri, 17 Sep 2010 08:39:17 +0000 Subject: [PATCH] add gangliamon configure git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7489 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/gangliamon.js | 116 ++++++++++++++++++++++++++++ xCAT-UI/js/monitor/monitor.js | 8 +- xCAT-UI/js/ui.js | 2 +- xCAT-server/lib/xcat/plugins/web.pm | 42 +++++++++- 4 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 xCAT-UI/js/monitor/gangliamon.js diff --git a/xCAT-UI/js/monitor/gangliamon.js b/xCAT-UI/js/monitor/gangliamon.js new file mode 100644 index 000000000..734743287 --- /dev/null +++ b/xCAT-UI/js/monitor/gangliamon.js @@ -0,0 +1,116 @@ +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(); + } + }); +} \ No newline at end of file diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index 8b7186001..ee0a5e403 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -70,7 +70,8 @@ function loadMonitorPage() { "subsystem is our recommended software for monitoring xCAT clusters. It's is part " + "of the IBM's Reliable Scalable Cluster Technology (RSCT) that provides a comprehensive " + "clustering environment for AIX and LINUX.
  • "; - items += "
  • Ganglia Monitor :
  • "; + items += "
  • Ganglia Monitor : Ganglia is a scalable distributed " + + "monitoring system for high-performance computing systems such as clusters and Grids.
  • "; items += "
  • PCP Monitor :
  • "; monitorList.append(items); @@ -175,7 +176,8 @@ function loadMonitorTab(monitorName){ loadRmcMon(); break; case 'gangliamon': - loadUnfinish(monitorName, tab); + tab.add(monitorName, 'Ganglia Monitor', '', true); + loadGangliaMon(); break; case 'pcpmon': loadUnfinish(monitorName, tab); @@ -189,5 +191,5 @@ function loadUnfinish(monitorName, tab){ var unfinishPage = $('
    '); unfinishPage.append(createInfoBar('under construction.')); - tab.add(monitorName, 'unfinish', unfinishPage, '', true); + tab.add(monitorName, 'unfinish', unfinishPage, true); } \ No newline at end of file diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index 3cb6bc6a1..6a79983f2 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -446,7 +446,7 @@ function initPage() { } else if (page == 'monitor.php') { includeJs("js/monitor/xcatmon.js"); includeJs("js/monitor/rmcmon.js"); - + includeJs("js/monitor/gangliamon.js"); headers.eq(3).css('background-color', '#A9D0F5'); loadMonitorPage(); } else { diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index 29e356a46..6c289a148 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -52,6 +52,7 @@ sub process_request 'unlock' => \&web_unlock, 'rmcstart' => \&web_rmcmonStart, 'rmcshow' => \&web_rmcmonShow, + 'gangliaStart' => \&web_gangliamonStart, #'xdsh' => \&web_xdsh, #THIS list needs to be updated @@ -433,7 +434,7 @@ sub web_rmcmonStart{ $callback->({info=>'RMC Monitoring is running now.'}); return; } - } + } $retData .= "RMC is not running, start it now.\n"; @@ -631,4 +632,43 @@ sub web_rmcmonShow(){ #push the last attribute name and values. push(@{$retHash->{node}}, {name=>$attrName, data=>join(',', @attrValue)}); $callback->($retHash); +} + +sub web_gangliamonStart(){ + my ( $request, $callback, $sub_req ) = @_; + my $table; + my $retInfo; + my $output; + + #check the running status + $table = xCAT::Table->new('monitoring'); + my $gangWorkingStatus = $table->getAttribs({name => 'gangliamon'}, 'disable'); + $table.close(); + + #the rmc monitoring is running so return directly + if($gangWorkingStatus){ + if ($gangWorkingStatus->{disable} =~ /0|No|no|NO|N|n/){ + $callback->({info=>'Ganglia Monitoring is running now.'}); + return; + } + } + + #run configure commands + $output = xCAT::Utils->runcmd('monadd gangliamon', -1, 1); + foreach($output){ + $retInfo .= ($_ . "\n"); + } + + $output = xCAT::Utils->runcmd('moncfg gangliamon -r', -1, 1); + foreach($output){ + $retInfo .= ($_ . "\n"); + } + + $output = xCAT::Utils->runcmd('monstart gangliamon -r', -1, 1); + foreach($output){ + $retInfo .= ($_ . "\n"); + } + + $callback->({info=>$retInfo}); + return; } \ No newline at end of file