From 4110c9290c1791dae0cafeac282e6758c0281bdb Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 12 Jan 2011 10:43:45 +0000 Subject: [PATCH] show the monitor status on monitor tab git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8626 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/monitor.js | 91 ++++++++++++++++++++--------- xCAT-server/lib/xcat/plugins/web.pm | 23 ++++++++ 2 files changed, 88 insertions(+), 26 deletions(-) diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index 494acbe86..e8ef525e3 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -54,35 +54,74 @@ function loadMonitorPage() { var monitorForm = $('
'); // Create info bar - var monitorInfoBar = createInfoBar('Select a monitoring tool to use.'); - monitorForm.append(monitorInfoBar); + monitorForm.append('Getting monitoring stauts').append(createLoader()); - // Create a list of monitoring tools - var monitorList = $('
    '); - var items = "
  1. xCAT Monitor : xcatmon provides node status " - + "monitoring using fping on AIX and nmap on Linux. It also provides application " - + "status monitoring. The status and the appstatus columns of the nodelist table " - + "will be updated periodically with the latest status values for the nodes.
  2. "; - items += "
  3. RMC Monitor : IBM's Resource Monitoring and Control (RMC) " - + "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.
  4. "; - items += "
  5. RMC Event : Listing event monitoring information " - + "recorded by the RSCT Event Response resource manager in the audit log. Creating and " - + "removing a condition/response association.
  6. "; - items += "
  7. Ganglia Monitor : Ganglia is a scalable distributed " - + "monitoring system for high-performance computing systems such as clusters and Grids.
  8. "; - items += "
  9. PCP Monitor : Under construction.
  10. "; - monitorList.append(items); - - // Open new tab for monitor tool - $('a', monitorList).click(function() { - loadMonitorTab($(this).attr('name')); - }); - - monitorForm.append(monitorList); + tab.add('monitorTab', 'Monitor', monitorForm, false); + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : 'monls', + msg : '' + }, + + success : function(data){ + var monitorTable = ''; + var monitorStatusHash = new Object(); + if (data.rsp[0]){ + var tempArray = data.rsp[0].split(';'); + var position = 0; + var name = ''; + var status = ''; + for(var i in tempArray){ + position = tempArray[i].indexOf(':'); + if(-1 == position){ + continue; + } + name = tempArray[i].substr(0, position); + status = tempArray[i].substr(position + 1); + monitorStatusHash[name] = status; + } + } + //xcat monitor + monitorTable += ''; + monitorTable += ''; + monitorTable += ''; + + //rmc monitor + monitorTable += ''; + monitorTable += ''; + monitorTable += ''; + + //rmc event + monitorTable += ''; + monitorTable += ''; + monitorTable += ''; + + //ganglia event + monitorTable += ''; + monitorTable += ''; + monitorTable += ''; + + //pcp monitor + monitorTable += ''; + monitorTable += ''; + monitorTable += ''; + + monitorTable += '
    Monitor ToolStatusDescription
    xCAT Monitor' + monitorStatusHash['xcatmon'] + 'Provides node status monitoring using fping on AIX and nmap on Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.
    RMC Monitor' + monitorStatusHash['rmcmon'] + 'IBM\'s Resource Monitoring and Control (RMC) 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.
    RMC Event' + monitorStatusHash['rmcmon'] + 'Listing event monitoring information recorded by the RSCT Event Response resource manager in the audit log. Creating and removing a condition/response association.
    Ganglia Monitor' + monitorStatusHash['gangliamon'] + 'A scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.
    PCP MonitorundefinedUnder construction.
    '; + + $('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use.')); + $('#monitorTab .form').append(monitorTable); + + $('#monitorTab .form a').bind('click', function() { + loadMonitorTab($(this).attr('name')); + }); + } + }); /** * Monitor resources */ diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index cc9e963b7..9432855af 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -54,6 +54,7 @@ sub process_request { 'gangliastatus' => \&web_gangliastatus, 'gangliacheck' => \&web_gangliacheck, 'mkcondition' => \&web_mkcondition, + 'monls' => \&web_monls, #'xdsh' => \&web_xdsh, #THIS list needs to be updated ); @@ -954,3 +955,25 @@ sub web_rmcmonShow() { push( @{ $retHash->{node} }, { name => $attrName, data => join( ',', @attrValue ) } ); $callback->($retHash); } + +sub web_monls(){ + my ( $request, $callback, $sub_req ) = @_; + my $retInfo = xCAT::Utils->runcmd( "monls", -1, 1 ); + my $ret = ''; + foreach my $line (@$retInfo){ + my @temp = split(/\s+/, $line); + $ret .= @temp[0]; + if('not-monitored' eq @temp[1]){ + $ret .= ':Not Monitored;'; + } + else{ + $ret .= ':Monitored;'; + } + } + if ('' eq $ret){ + return; + } + + $ret = substr($ret, 0, length($ret) - 1); + $callback->({data=>$ret}); +} \ No newline at end of file