From a33e97a3093770697585b8971734d34c7f0b2274 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 4 Aug 2010 08:49:20 +0000 Subject: [PATCH] modified and added by xuqing for xCAT Monitor and RMC Monitor git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6970 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/monitor/monitor.js | 60 ++++++++++++- xCAT-UI/js/monitor/rmcmon.js | 98 ++++++++++++++++++++ xCAT-UI/js/monitor/xcatmon.js | 162 ++++++++++++++++++++++++++++++++++ xCAT-UI/js/ui.js | 2 + 4 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 xCAT-UI/js/monitor/rmcmon.js create mode 100644 xCAT-UI/js/monitor/xcatmon.js diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index 32f4d95aa..b86b8c85b 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -54,13 +54,32 @@ function loadMonitorPage() { var monitorForm = $('
'); // Create info bar - var monitorInfoBar = createInfoBar('Under construction'); + var monitorInfoBar = createInfoBar('Select the Monitor Tool'); monitorForm.append(monitorInfoBar); // Create drop-down menu // Hardware available to provision - ipmi, blade, hmc, ivm, fsp, and zvm - var div = $('
'); - monitorForm.append(div); + + var monitorList = $(''); + var items = "
  • 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.
  • "; + + items += "
  • 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.
  • "; + items += "
  • Ganglia Monitor :
  • "; + items += "
  • PCP Monitor :
  • "; + + monitorList.append(items); + + $('a', monitorList).click(function(){ + loadMonitorTab($(this).attr('name')); + }); + + monitorForm.append(monitorList); tab.add('monitorTab', 'Monitor', monitorForm, false); /** @@ -136,4 +155,39 @@ function loadMonitorPage() { resrcForm.append(okBtn); tab.add('resourceTab', 'Resources', resrcForm, false); +} + +function loadMonitorTab(monitorName){ + //the tab is exist then we only need to select it + var tab = getMonitorTab(); + if (0 != $("#" + monitorName).length){ + tab.select(monitorName); + return; + } + + switch(monitorName){ + case 'xcatmon': + tab.add(monitorName, 'xCAT Monitor', '', true); + loadXcatMon(); + break; + case 'rmcmon': + tab.add(monitorName, 'RMC Monitor', '', true); + loadRmcMon(); + break; + case 'gangliamon': + loadUnfinish(monitorName, tab); + break; + case 'pcpmon': + loadUnfinish(monitorName, tab); + break; + } + + tab.select(monitorName); +} + +function loadUnfinish(monitorName, tab){ + var unfinishPage = $('
    '); + unfinishPage.append(createInfoBar('under construction.')); + + tab.add(monitorName, 'unfinish', unfinishPage, '', true); } \ No newline at end of file diff --git a/xCAT-UI/js/monitor/rmcmon.js b/xCAT-UI/js/monitor/rmcmon.js new file mode 100644 index 000000000..f0890315e --- /dev/null +++ b/xCAT-UI/js/monitor/rmcmon.js @@ -0,0 +1,98 @@ +function loadRmcMon(){ + //find the rmcmon tab + var rmcMonTab = $('#rmcmon'); + + //add the stauts bar first. id = 'rmcMonStatus' + var rmcStatusBar = createStatusBar('rmcMonStatus'); + rmcStatusBar.append(createLoader()); + rmcMonTab.append(rmcStatusBar); + + //add the configure button. + var configButton = createButton('Configure'); + configButton.click(function(){ + if ($('#rmcMonConfig').is(':hidden')){ + $('#rmcMonConfig').show(); + } + else{ + $('#rmcMonConfig').hide(); + } + }); + rmcMonTab.append(configButton); + + //add configure div + rmcMonTab.append("
    "); + $('#rmcMonConfig').hide(); + + //load the configure div's content + loadRmcMonConfigure(); + + //add the content of the rmcmon, id = 'rmcMonTab' + rmcMonTab.append("
    "); + + //check the software work status by platform(linux and aix) + $.ajax( { + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'ostype' + }, + + success : rsctRpmCheck + }); +} + +function loadRmcMonConfigure(){ + $('#rmcMonConfig').append('under construction.'); +} +function rsctRpmCheck(data){ + //linux had to check the rscp first + if ('aix' != data.rsp){ + $.ajax( { + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'rpm -q rsct.core' + }, + + success : function(data){ + if (-1 != data.rsp.indexOf("not")){ + $('#rmcMonStatus').empty().append('Please install the RSCT first.
    The software can be downloaded from ' + + 'RSCT\'s RMC subsystem.
    ' + + 'You can find more support form xCAT2-Monitoring.pdf'); + } + else{ + xcatrmcRpmCheck(); + } + } + }); + } + else{ + xcatrmcRpmCheck(); + } +} + +function xcatrmcRpmCheck(){ + $.ajax( { + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'rpm -q xCAT-rmc' + }, + + success : function(data){ + if(-1 != data.rsp.indexOf("not")){ + $('#rmcMonStatus').empty().append('Please install the xCAT-rmc first.
    The software can be downloaded from ' + + 'xCAT Download Page.
    '+ + 'You can find more support form xCAT2-Monitoring.pdf'); + } + else{ + loadRmcMonShow(); + } + } + }); +} + +function loadRmcMonShow(){ + $('#rmcMonStatus').empty().append('The RMC Monitor is under construction.'); + $('#rmcMonShow').empty().append('under construction.'); +} \ No newline at end of file diff --git a/xCAT-UI/js/monitor/xcatmon.js b/xCAT-UI/js/monitor/xcatmon.js new file mode 100644 index 000000000..bd8b6a1ea --- /dev/null +++ b/xCAT-UI/js/monitor/xcatmon.js @@ -0,0 +1,162 @@ +function loadXcatMon(){ + //find the xcat mon tab + var xcatMonTab = $('#xcatmon'); + + //add the stauts bar first. id = 'xcatMonStatus' + var StatusBar = createStatusBar('xcatMonStatus'); + StatusBar.append(createLoader()); + xcatMonTab.append(StatusBar); + + //add the configure button. + var configButton = createButton('Configure'); + configButton.click(function(){ + if ($('#xcatMonConfig').is(':hidden')){ + $('#xcatMonConfig').show(); + } + else{ + $('#xcatMonConfig').hide(); + } + }); + xcatMonTab.append(configButton); + + //add the configure div, id = 'xcatMonConfig' + xcatMonTab.append("
    "); + $('#xcatMonConfig').hide(); + + //add button start, stop, cancel to the monconfig div + loadXcatMonConfigure(); + + //add the content of the xcat mon, id = 'xcatMonShow' + xcatMonTab.append("
    "); + + //show the content of the page. + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'monls', + tgt : '', + args : 'xcatmon', + msg : '' + }, + + success : loadXcatMonWorkStatus + }); +} + +function loadXcatMonWorkStatus(data){ + var xcatWorkStatus = data.rsp[0]; + + //the xcat mon did not run + if (-1 != xcatWorkStatus.indexOf('not-monitored')){ + $('#xcatMonStatus').empty().append('The xCAT Monitor is not working. Please start it first.'); + return; + } + + //the xcatmon is running, show the result + loadXcatMonShow(); +} + +function loadXcatMonConfigure(){ + //get the xcat mon configure div + var xcatMonConfigDiv = $('#xcatMonConfig'); + xcatMonConfigDiv.empty(); + + //add start button + var startButton = createButton('Start'); + xcatMonConfigDiv.append(startButton); + startButton.click(function(){ + $('#xcatMonStatus').empty().append(createLoader()); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'monstart', + tgt : '', + args : 'xcatmon', + msg : '' + }, + + success : function(data){ + //update the status bar, update the xcatmon show + $('#xcatMonStatus').empty().append(data.rsp[0]); + loadXcatMonShow(); + } + }); + }); + + //add stop buttons + var stopButton = createButton('Stop'); + xcatMonConfigDiv.append(stopButton); + stopButton.click(function(){ + $('#xcatMonStatus').empty().append(createLoader()); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'monstop', + tgt : '', + args : 'xcatmon', + msg : '' + }, + + success : function(data){ + $('#xcatMonStatus').empty().append(data.rsp[0]); + $('#xcatMonShow').empty(); + } + }); + }); + + //add cancel button + var cancelButton = createButton('Cancel'); + xcatMonConfigDiv.append(cancelButton); + cancelButton.click(function(){ + $('#xcatMonConfig').hide(); + }); +} + +function loadXcatMonShow(){ + //update the status bar into waiting + $('#xcatMonStatus').empty().append(createLoader()); + + //get the latest xcatmon information + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodestat', + tgt : 'lpar', + args : '', + msg : '' + }, + + success : updateXcatMonShow + }); +} + +function updateXcatMonShow(data){ + var temp = 0; + var nodeStatus = data.rsp; + var show = ""; + var tempArray; + //update the status bar + $('#xcatMonStatus').empty().append("Get nodes' status finished."); + + $('#xcatMonShow').empty(); + $('#xcatMonShow').append("
    Node Status
    "); + + //get the nodestat from return data + //the data.rsp is an array, it look like this: + //['node1:ssh', 'node2:noping', 'node3:ssh'] + for (temp = 0; temp < nodeStatus.length; temp++){ + tempArray = nodeStatus[temp].split(':'); + show += '

    ' + tempArray[0] + ':' + tempArray[1] + '

    '; + } + $('#xcatMonShow fieldset').append(show); + + var refreshButton = createButton('Refresh'); + $('#xcatMonShow fieldset').append(refreshButton); + refreshButton.click(function(){ + loadXcatMonShow(); + }); +} \ No newline at end of file diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index 4603443be..d9576e037 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -407,6 +407,8 @@ function initPage() { includeJs("js/jquery/jquery.tree.js"); includeJs("js/configure/configure.js"); includeJs("js/configure/update.js"); + includeJs("js/monitor/xcatmon.js"); + includeJs("js/monitor/rmcmon.js"); includeJs("js/monitor/monitor.js"); includeJs("js/nodes/nodes.js"); includeJs("js/provision/provision.js");