# DCremote.ctl:E900:Performs the Remote Data Collections # $Id: DCremote.ctl,v 1.7 2013/10/30 07:18:47 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/RDA/DCremote.ctl,v 1.7 2013/10/30 07:18:47 RDA Exp $ # # Change History # 20130517 JJU Improve the installation. =head1 NAME RDA:DCremote - Performs the Remote Data Collections =head1 DESCRIPTION This module performs the remote data collection. For each node: =over 4 =item * It determines the storage type (that is, LOCAL, SHARED, SPLIT, or REMOTE), by transferring the remote setup file. =item * It installs the RDA software if it is not installed already. The installation is checked. =item * It runs RDA on the remote node and packages the reports. =item * It transfers the resulting report package back. =back =cut use Remote echo tput('bold'),'Processing RDA.REMOTE module ...',tput('off') # Initialization if !@{COL.REMOTE.W_NODES} return var @nod = last #------------------------------------------------------------------------------ # Define macros #------------------------------------------------------------------------------ # Check a remote installation macro check_install {var ($nod,$flg) = @arg # Check the remote RDA installation if rda($nod,'-XRda check -R',true) {if !$flg return 1 # Check for file alterations if !getRemoteLines() return 1 loop $lin (last) {if !match($lin,'^\s*(RDA-(00012|01603):|(\*\s+)?File .* altered$)') return 1 } } # Indicate a successful RDA installation return 0 } # Get a remote setting macro get_node return ${<'COL/REMOTE',$arg[0],$arg[1]>:$arg[2]} # Define the storage detection macro macro get_storage {var ($nod,$loc,$rem,$wrk) = @arg var $nam = getRemoteSetup($nod) # Detect a local node if !isRemote($nod) {if transfer($loc,$nam,$rem,$nam,true) return ('R','W_STORAGE=LOCAL') else return ('n') } # When needed, create the remote directory call rexec($nod,concat('mkdir -p ',quote($rem))) # Test the transfer of the setup file if put($nod,$loc,$nam,$rem,$nam) return ('n') # Detect if RDA software and data collection are separated if get_node($nod,'_SPLIT') return ('I','W_STORAGE=SPLIT') # Detect the current install is shared with the remote node if ?testFile('r',catFile($rem,$nam)) return ('I','W_STORAGE=SHARED') # Otherwise assume a remote storage return ('I','W_STORAGE=REMOTE') } # Define the software installation macro macro do_install {var ($nod,$top) = @arg # Determine if software alterations are allowed var $flg = or(${COL.REMOTE.B_ALTER_ALLOWED},get_node($nod,'B_SPLIT')) # When not yet done, install the software var $pth = quote($top) if check_install($nod,$flg) {# When needed, create or modify the remote directory if expr('>',last,0) call rexec($nod,concat('mkdir -p ',$pth)) else call rexec($nod,concat('chmod -R u+w ',$pth)) # Transfer RDA software if mput($nod,true,\ ${CFG.D_RDA},'(^rda[\.\_]|sdci[\.\_]|\.txt$|^Convert$|^I?RDA$|\ ^admin$|^collect$|^da$|^dfw|^engine$|^hcve$|^mesg$)',\ $top) return 'i' if match(getRemoteSession($nod)->get_type,'^(da|jsch)$') call rexec($nod,join($pth,'chmod a+x ',\ '/*.cmd ','/*.com ','/*.exe ','/*.pl ','/*.sh ','/engine/rda_*')) # Check the remote software allowing only altered modules if check_install($nod,$flg) return 'c' } # Indicate a successful completion return 'R' } # Define the RDA run macro macro do_run {var ($nod,$wrk,$set,$nxt) = @arg if get_node($nod,$set) var $opt = last else var $opt = ${<'COL/REMOTE',$set>:'-vyXRda collect -SRPpRemote'} if rda($nod,concat(' -s',catFile($wrk,getRemoteSetup($nod)),' ',$opt)) return 'r' # Indicate a successful completion return $nxt } # Define the package transfer macro macro do_transfer {var ($nod,$rem,$loc) = @arg if match(get_node($nod,'W_STORAGE'),'^(LOCAL|SHARED)$') {var $pat = concat('^RDA_',lc($nod),'_',${CUR.W_COLLECTOR},'\.') loop $fil (grepDir($rem,$pat,'iu')) {if !transfer($rem,$fil,$loc) return 't' } } elsif mget($nod,false,\ $rem,concat('RDA_',lc($nod),'_',${CUR.W_COLLECTOR},'.*'),\ $loc) return 't' # Indicate a successful completion return '-' } #------------------------------------------------------------------------------ # Perform the remote data collection #------------------------------------------------------------------------------ # Check if there are pending remote requests call initSteps() loop $nod (@nod) {if and(isRemote($nod),match(getStep($nod,'N'),'[A-Z]')) {call initRemote() break } } # Check if a post treatment must be performed var $pst = ${COL.REMOTE.T_POST_OPTIONS} if $pst var $nxt = 'P' else var $nxt = 'T' # Create the 'remote' directory call getDir('D',true) # Perform the data collection in separate threads loop $nod (@nod) {thread {import $nod,$nxt var $cwd = ${CFG.D_CWD} var $stp = getStep($nod,'N') var $pre = get_node($nod,'W_PREFIX',$nod) var $top = get_node($nod,'T_HOME',${CFG.D_RDA}) var $wrk = get_node($nod,'T_WORK',$cwd) # Detect the storage type of the remote node if compare('eq',$stp,'N') {debug $pre,': Detecting storage type' var $stp = setStep($nod,get_storage($nod,${OUT.P},$wrk)) } # Install the software on the remote node if compare('eq',$stp,'I') {debug $pre,': Installing RDA software' var $stp = setStep($nod,do_install($nod,$top)) } # Execute remotely RDA command if compare('eq',$stp,'R') {debug $pre,': Running RDA command' var $stp = setStep($nod,do_run($nod,$wrk,'T_RDA_OPTIONS',$nxt)) } # Transfert the report package if compare('eq',$stp,'T') {debug $pre,': Transfering report package' var $stp = setStep($nod,do_transfer($nod,$wrk,${OUT.D})) } } } wait call endSteps() # Perform the post treatment in separate threads if $pst {call initSteps() loop $nod (@nod) {thread {var $stp = getStep($nod,'N') var $pre = get_node($nod,'W_PREFIX',$nod) var $wrk = get_node($nod,'T_WORK',${CFG.D_CWD}) # Execute remotely RDA command if compare('eq',$stp,'P') {debug $pre,': Performing RDA post treatment' var $stp = setStep($nod,do_run($nod,$wrk,'T_POST_OPTIONS','T')) } # Transfert the report package if compare('eq',$stp,'T') {debug $pre,': Transfering report package' var $stp = setStep($nod,do_transfer($nod,$wrk)) } } } wait call endSteps() } =begin credits =over 10 =item RDA 4.2: Roger Snowden. =item RDA 4.5: Bob Caldwell. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut