2010-08-26 05:27:11 +00:00
var globalErrNodes ;
var globalNodesDetail ;
var globalAllNodesNum = 0 ;
var globalFinishNodesNum = 0 ;
2010-08-04 08:49:20 +00:00
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' ) ;
2010-08-22 14:58:21 +00:00
configButton . hide ( ) ;
2010-08-04 08:49:20 +00:00
configButton . click ( function ( ) {
if ( $ ( '#rmcMonConfig' ) . is ( ':hidden' ) ) {
$ ( '#rmcMonConfig' ) . show ( ) ;
}
else {
$ ( '#rmcMonConfig' ) . hide ( ) ;
}
2010-09-14 08:06:50 +00:00
} ) ;
2010-08-04 08:49:20 +00:00
rmcMonTab . append ( configButton ) ;
//add configure div
rmcMonTab . append ( "<div id='rmcMonConfig'></div>" ) ;
$ ( '#rmcMonConfig' ) . hide ( ) ;
//load the configure div's content
loadRmcMonConfigure ( ) ;
//add the content of the rmcmon, id = 'rmcMonTab'
2010-09-14 08:06:50 +00:00
rmcMonTab . append ( "<div id='rmcMonShow'><div id='rmcmonSummary'></div><div id='rmcmonDetail'></div><div id='nodeDetail'></div></div>" ) ;
$ ( '#nodeDetail' ) . hide ( ) ;
2010-08-04 08:49:20 +00:00
//check the software work status by platform(linux and aix)
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : 'ostype'
} ,
success : rsctRpmCheck
} ) ;
}
function loadRmcMonConfigure ( ) {
2010-08-22 14:58:21 +00:00
//get the configure div and clean its content.
var rmcmonCfgDiv = $ ( '#rmcMonConfig' ) ;
rmcmonCfgDiv . empty ( ) ;
//add the start button
var startButton = createButton ( 'Start' ) ;
rmcmonCfgDiv . append ( startButton ) ;
startButton . click ( function ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rmcstart;lpar' ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
}
} ) ;
} ) ;
//add the stop button
var stopButton = createButton ( 'Stop' ) ;
rmcmonCfgDiv . append ( stopButton ) ;
stopButton . click ( function ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'monstop' ,
tgt : '' ,
args : 'rmcmon' ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
}
} ) ;
} ) ;
//add the cancel button
var cancelButton = createButton ( 'Cancel' ) ;
rmcmonCfgDiv . append ( cancelButton ) ;
cancelButton . click ( function ( ) {
$ ( '#rmcMonConfig' ) . hide ( ) ;
} ) ;
2010-08-04 08:49:20 +00:00
}
2010-08-26 05:27:11 +00:00
2010-08-04 08:49:20 +00:00
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" ) ) {
2010-08-22 14:58:21 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append (
'Please install the <a href="http://www14.software.ibm.com/webapp/set2/sas/f/rsct/rmc/download/home.html" target="install_window">RSCT</a> first.<br/>' +
2010-08-04 08:49:20 +00:00
'You can find more support form <a href="http://xcat.svn.sourceforge.net/viewvc/xcat/xcat-core/trunk/xCAT-client/share/doc/xCAT2-Monitoring.pdf" target="pdf_window">xCAT2-Monitoring.pdf</a>' ) ;
}
else {
xcatrmcRpmCheck ( ) ;
}
}
} ) ;
}
else {
xcatrmcRpmCheck ( ) ;
}
}
function xcatrmcRpmCheck ( ) {
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
2010-08-22 14:58:21 +00:00
cmd : 'rpm -q xCAT-rmc rrdtool'
2010-08-04 08:49:20 +00:00
} ,
success : function ( data ) {
2010-08-22 14:58:21 +00:00
var softInstallStatus = data . rsp . split ( /\n/ ) ;
var needHelp = false ;
$ ( '#rmcMonStatus' ) . empty ( ) ;
//check the xcat-rmc
if ( - 1 != softInstallStatus [ 0 ] . indexOf ( "not" ) ) {
needHelp = true ;
$ ( '#rmcMonStatus' ) . append (
'Please install the <a href="http://xcat.sourceforge.net/#download" target="install_window">xCAT-rmc</a> first.<br/>' ) ;
}
//check the rrdtool
if ( - 1 != softInstallStatus [ 1 ] . indexOf ( "not" ) ) {
needHelp = true ;
$ ( '#rmcMonStatus' ) . append (
'Please install the <a href="http://oss.oetiker.ch/rrdtool/download.en.html" target="install_window">RRD-tool</a> first.<br/>' ) ;
}
//add help info or load the rmc show
if ( needHelp ) {
$ ( '#rmcMonStatus' ) . append (
'You can find more support form <a href="http://xcat.svn.sourceforge.net/viewvc/xcat/xcat-core/trunk/xCAT-client/share/doc/xCAT2-Monitoring.pdf" target="pdf_window">xCAT2-Monitoring.pdf</a>' ) ;
2010-08-04 08:49:20 +00:00
}
else {
2010-08-22 14:58:21 +00:00
rmcWorkingCheck ( ) ;
2010-08-04 08:49:20 +00:00
}
}
} ) ;
}
2010-08-22 14:58:21 +00:00
function rmcWorkingCheck ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Checking RMC working status." ) ;
$ ( '#rmcMonStatus' ) . append ( createLoader ( ) ) ;
$ ( '#rmcmon button:first' ) . show ( ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'monls' ,
tgt : '' ,
args : 'rmcmon' ,
msg : ''
} ,
success : function ( data ) {
if ( - 1 != data . rsp [ 0 ] . indexOf ( "not-monitored" ) ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Please start the RMC Monitoring first." ) ;
return ;
}
loadRmcMonShow ( ) ;
}
} ) ;
}
2010-08-04 08:49:20 +00:00
function loadRmcMonShow ( ) {
2010-08-26 05:27:11 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Getting monitoring Data." ) ;
$ ( '#rmcMonStatus' ) . append ( createLoader ( ) ) ;
//load the rmc status summary
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rmcshow;summary' ,
msg : ''
} ,
success : function ( data ) {
showRmcSummary ( data . rsp [ 0 ] ) ;
}
} ) ;
//load each nodes' status
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rmcshow;lpar' ,
msg : ''
} ,
success : function ( data ) {
parseRmcData ( data . rsp ) ;
}
} ) ;
}
function showRmcSummary ( returnData ) {
var attributes = returnData . split ( ';' ) ;
var attr ;
var attrName ;
var attrValues ;
var attrDiv ;
var summaryTable = $ ( '<table><tbody></tbody></table>' ) ;
var summaryRow ;
$ ( '#rmcmonSummary' ) . empty ( ) . append ( '<h3>Overview</h3><hr />' ) ;
$ ( '#rmcmonSummary' ) . append ( summaryTable ) ;
for ( attr in attributes ) {
var tempTd = $ ( '<td style="border:0px;padding:15px 5px;"></td>' ) ;
var tempArray = [ ] ;
var temp = attributes [ attr ] . indexOf ( ':' ) ;
attrName = attributes [ attr ] . substr ( 0 , temp ) ;
attrValues = attributes [ attr ] . substr ( temp + 1 ) . split ( ',' ) ;
for ( var i in attrValues ) {
tempArray . push ( [ i , attrValues [ i ] ] ) ;
}
if ( 0 == ( attr % 3 ) ) {
summaryRow = $ ( '<tr></tr>' ) ;
summaryTable . append ( summaryRow ) ;
}
summaryRow . append ( tempTd ) ;
attrDiv = $ ( '<div class="monitorsumdiv"></div>' ) ;
tempTd . append ( attrDiv ) ;
$ . plot ( attrDiv , [ tempArray ] ) ;
attrDiv . append ( '<center>' + attrName + '</center>' ) ;
}
}
function parseRmcData ( returnData ) {
var nodeName ;
var nodeStatus ;
var nodeChat ;
//clean all the history data, because all of the follow variables are global
globalAllNodesNum = returnData . length ;
globalFinishNodesNum = 0 ;
globalErrNodes = { } ;
globalNodesDetail = { } ;
for ( var i in returnData ) {
var temp = returnData [ i ] . indexOf ( ':' ) ; ;
nodeName = returnData [ i ] . substr ( 0 , temp ) ;
nodeStatus = returnData [ i ] . substr ( temp + 1 ) . replace ( /(^\s*)|(\s*$)/g , '' ) ;
//not active nodes
if ( 'OK' != nodeStatus ) {
globalErrNodes [ nodeName ] = nodeStatus ;
globalFinishNodesNum ++ ;
if ( globalFinishNodesNum == globalAllNodesNum ) {
2010-09-14 08:06:50 +00:00
showDetail ( ) ;
2010-08-26 05:27:11 +00:00
}
continue ;
}
//ok
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rmcshow;' + nodeName ,
msg : nodeName
} ,
success : function ( data ) {
var tempObject = { } ;
for ( var i in data . rsp ) {
var temp = data . rsp [ i ] . indexOf ( ':' ) ;
var attrName = data . rsp [ i ] . substr ( 0 , temp ) ;
tempObject [ attrName ] = data . rsp [ i ] . substr ( temp + 1 ) ;
}
globalNodesDetail [ data . msg ] = tempObject ;
globalFinishNodesNum ++ ;
if ( globalFinishNodesNum == globalAllNodesNum ) {
2010-09-14 08:06:50 +00:00
showDetail ( ) ;
2010-08-26 05:27:11 +00:00
}
}
} ) ;
}
}
2010-09-14 08:06:50 +00:00
function showDetail ( ) {
2010-08-26 05:27:11 +00:00
var nodeChat ;
2010-09-13 08:44:19 +00:00
var select ;
2010-08-26 05:27:11 +00:00
2010-09-13 08:44:19 +00:00
var detailFilter = $ ( '<div id="detailFilter"></div>' ) ;
2010-08-26 05:27:11 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "RMC Monitoring Show" ) ;
$ ( '#rmcmonDetail' ) . empty ( ) . append ( '<h3>Detail</h3><hr />' ) ;
2010-09-13 08:44:19 +00:00
$ ( '#rmcmonDetail' ) . append ( detailFilter ) ;
select = $ ( '<select id="metric"></select>' ) ;
for ( var node in globalNodesDetail ) {
for ( var attr in globalNodesDetail [ node ] ) {
select . append ( '<option value="' + attr + '">' + attr + '</option>' ) ;
}
break ;
}
detailFilter . append ( '<b>Metric: </b>' ) ;
detailFilter . append ( select ) ;
detailFilter . append ( ' ' ) ;
//sort type
select = $ ( '<select id="sortType"></select>' ) ;
select . append ( '<option value="1">ascend</option>' ) ;
select . append ( '<option value="2">descend</option>' ) ;
select . append ( '<option value="3">node name</option>' ) ;
detailFilter . append ( '<b>Sort: </b>' ) ;
detailFilter . append ( select ) ;
detailFilter . append ( ' ' ) ;
var filterButton = createButton ( 'Filter' ) ;
detailFilter . append ( filterButton ) ;
filterButton . bind ( 'click' , function ( ) {
var attr = $ ( '#metric' ) . val ( ) ;
var type = $ ( '#sortType' ) . val ( ) ;
showAllNodes ( attr , type ) ;
} ) ;
2010-09-14 08:06:50 +00:00
filterButton . trigger ( 'click' ) ;
2010-09-13 08:44:19 +00:00
}
function showAllNodes ( attrName , type ) {
$ ( '#rmcmonDetail table' ) . remove ( ) ;
var detailTable = $ ( '<table><tbody></tbody></table>' ) ;
//remember how many nodes parsed, used for adding new table row
var parseNum = 0 ;
var detailRow ;
var sortArray = new Array ( ) ;
2010-08-26 05:27:11 +00:00
$ ( '#rmcmonDetail' ) . append ( detailTable ) ;
for ( var nodeName in globalErrNodes ) {
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
if ( 0 == ( parseNum % 4 ) ) {
detailRow = $ ( '<tr></tr>' ) ;
detailTable . append ( detailRow ) ;
}
detailRow . append ( tempTd ) ;
parseNum ++ ;
nodeChat = $ ( '<div class="monitornodediv"></div>' ) ;
if ( 'NA' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#f47a55' ) ;
nodeChat . append ( '<center><h4> Not Active</h4></center>' ) ;
}
else if ( 'NI' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#ffce7b' ) ;
nodeChat . append ( '<center><h4>' + nodeName + '\'s RSCT is not installed.</h4></center>' ) ;
}
else if ( 'NR' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#ffce7b' ) ;
nodeChat . append ( '<center><h4>' + nodeName + '\'s RSCT is not started.</h4></center>' ) ;
}
tempTd . append ( nodeChat ) ;
tempTd . append ( '<center>' + nodeName + '</center>' ) ;
}
2010-09-13 08:44:19 +00:00
filterSort ( attrName , type , sortArray ) ;
for ( var sortIndex in sortArray ) {
2010-08-26 05:27:11 +00:00
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
if ( 0 == ( parseNum % 4 ) ) {
detailRow = $ ( '<tr></tr>' ) ;
detailTable . append ( detailRow ) ;
}
detailRow . append ( tempTd ) ;
parseNum ++ ;
nodeChat = $ ( '<div class="monitornodediv"></div>' ) ;
tempTd . append ( nodeChat ) ;
2010-09-13 08:44:19 +00:00
var tempData = sortArray [ sortIndex ] [ 'value' ] . split ( ',' ) ;
var tempArray = [ ] ;
for ( var i in tempData ) {
tempArray . push ( [ i , tempData [ i ] ] ) ;
2010-08-26 05:27:11 +00:00
}
2010-09-13 08:44:19 +00:00
$ . plot ( nodeChat , [ tempArray ] ) ;
tempTd . append ( '<center>' + sortArray [ sortIndex ] [ 'name' ] + '</center>' ) ;
2010-09-14 08:06:50 +00:00
tempTd . css ( 'cursor' , 'pointer' ) ;
tempTd . bind ( 'click' , function ( ) {
showNode ( $ ( 'center' , $ ( this ) ) . html ( ) ) ;
} ) ;
}
}
function showNode ( nodeName ) {
var nodeTable = $ ( '<table><tbody></tbody></table>' ) ;
var backButton = createButton ( 'Go back to all nodes' ) ;
var nodeRow ;
var parseNum = 0 ;
$ ( '#rmcmonDetail' ) . hide ( ) ;
$ ( '#nodeDetail' ) . empty ( ) . show ( ) ;
$ ( '#nodeDetail' ) . append ( '<h3>' + nodeName + ' Detail</h3><hr />' ) ;
$ ( '#nodeDetail' ) . append ( backButton ) ;
backButton . bind ( 'click' , function ( ) {
$ ( '#nodeDetail' ) . hide ( ) ;
$ ( '#rmcmonDetail' ) . show ( ) ;
} ) ;
$ ( '#nodeDetail' ) . append ( nodeTable ) ;
for ( var attr in globalNodesDetail [ nodeName ] ) {
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
var attrChat = $ ( '<div class="monitornodediv"></div>' ) ;
if ( 0 == parseNum % 4 ) {
nodeRow = $ ( '<tr></tr>' ) ;
nodeTable . append ( nodeRow ) ;
}
nodeRow . append ( tempTd ) ;
parseNum ++ ;
//data
tempTd . append ( attrChat ) ;
var tempData = globalNodesDetail [ nodeName ] [ attr ] . split ( ',' ) ;
var tempArray = [ ] ;
for ( var i in tempData ) {
tempArray . push ( [ i , tempData [ i ] ] ) ;
}
$ . plot ( attrChat , [ tempArray ] ) ;
attrChat . append ( '<center>' + attr + '</center>' ) ;
2010-09-13 08:44:19 +00:00
}
}
function filterSort ( attrName , sortType , retArray ) {
var tempObj = { } ;
for ( var node in globalNodesDetail ) {
tempObj [ 'name' ] = node ;
tempObj [ 'value' ] = globalNodesDetail [ node ] [ attrName ] ;
retArray . push ( tempObj ) ;
}
//by node name
if ( 3 == sortType ) {
retArray . sort ( sortName ) ;
}
//desend
else if ( 2 == sortType ) {
retArray . sort ( sortDes ) ;
}
//ascend
else {
retArray . sort ( sortAsc ) ;
}
return ;
}
function sortAsc ( x , y ) {
if ( x [ 'value' ] > y [ 'value' ] ) {
return 1 ;
}
else {
return - 1 ;
}
}
function sortDes ( x , y ) {
if ( x [ 'value' ] > y [ 'value' ] ) {
return - 1 ;
}
else {
return 1 ;
}
}
function sortName ( x , y ) {
if ( x [ 'name' ] > y [ 'name' ] ) {
return 1 ;
}
else {
return - 1 ;
2010-08-26 05:27:11 +00:00
}
2010-08-04 08:49:20 +00:00
}