# TLdiff.def: Compares two Systems # $Id: TLdiff.def,v 1.10 2008/02/25 13:38:59 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/TLdiff.def,v 1.10 2008/02/25 13:38:59 mschenke Exp $ # # Change History # 20080225 MSC Improve the documentation. =head1 NAME TLdiff - Compares Two Systems =head1 DESCRIPTION Compares two systems or two samples from the same system. For remote collections: =over 4 =item * A remote collection setup must be done. Use a command similar to the following: -vX Remote setup_cluster / =item * Data is extracted remotely on all nodes and transferred back into the C sub directory. Collected samples are regrouped in a result set. =back You can only compare samples from the same result set. A list of all samples, grouped by result sets, is available. =head1 USAGE This tool can be used in two ways: =over 3 =item a) Runs interactively. It requests the user to enter the required information. -vT diff =item b) Runs from the command line. The input can be given in the command line using the following syntax: -vT diff:A:,:[,...][:|...] Performs a data collection on all remote nodes. EsetE is the result name. -vT diff:B:,:[,...][:|...] Performs a data collection on the local host. EsetE is the result name. -vT diff:C::,:, Compares two data collections. -vT diff:D Lists all available samples, grouped by result set. =back =cut # Initialisation var $DIFF_FILE = '%s_DIFF_%s_%06d_%s.txt' var $MACHINE_NAME = getSetting('MACHINE_NAME') var $ORACLE_HOME = getSetting('ORACLE_HOME',getEnv('ORACLE_HOME','')) var $ORACLE_SID = getSetting('ORACLE_SID',getEnv('ORACLE_SID','')) var $RDA_WORK = getSetting('RDA_WORK') var $RPT_DIRECTORY = getSetting('RPT_DIRECTORY','output') var $RPT_GROUP = getSetting('RPT_GROUP','RDA') var $RE_SET = '^[A-Za-z]\w*$' var $TOP = '[[#Top][Back to top]]' var $TOC = '%TOC%' #------------------------------------------------------------------------------ # Define the remote operation macros #------------------------------------------------------------------------------ # Check a remote installation macro check_install {var ($nod,$flg) = @arg # Check the remote RDA installation if rda($nod,'-c',true) {if !$flg return 1 } # Check for any shell or RDA error loop $lin (getRemoteLines()) {if match($lin,'(^RDA-00014:|^\s+File .* altered$)') {next $flg return -1 } return 1 } # Indicate a successfull RDA installation return 0 } # Get a remote setting macro get_node return getSetting(concat('REMOTE_',$arg[0],$arg[1]),$arg[2]) # Define the storage detection macro macro get_storage {var ($nod,$loc,$rem) = @arg var $dst = getRemoteSetup($nod) var $src = getRemoteSetup($nod,true) # Detect a local node if !isRemote($nod) {if transfer($loc,$src,$rem,$dst,true) return ('R','_STORAGE=LOCAL') else return ('n') } # When needed, create the remote directory call rexec($nod,concat('mkdir -p ',$rem)) # Test the transfer of the setup file if put($nod,$loc,$src,$rem,$dst) return ('n') # Detect if RDA software and data collection are separated if get_node($nod,'_SPLIT') return ('I','_STORAGE=SPLIT') # Detect the current install is shared with the remote node if testFile('r',catFile($rem,$dst)) return ('I','_STORAGE=SHARED') # Otherwise assume a remote storage return ('I','_STORAGE=REMOTE') } # Define the software installation macro macro do_install {var ($nod,$top) = @arg # Determine if software alterations are allowed var $flg = or(getSetting('REMOTE_ALTER_ALLOWED'),get_node($nod,'_SPLIT')) # When not yet done, install the software if check_install($nod,$flg) {# When needed, create or modify the remote directory if expr('>',last,0) call rexec($nod,concat('mkdir -p ',$top)) else call rexec($nod,concat("chmod -R u+w ",$top)) # Transfer RDA software if mput($nod,true,'.','(^rda[\.\_]|\.txt$|^RDA$|^modules$)',$top) return 'i' # Check the remote software allowing only altered modules if check_install($nod,$flg) return 'c' } # Indicate a successful completion return 'R' } macro do_run {var ($nod,$wrk,$set,$num,$typ,$dir) = @arg import $RPT_GROUP if rda($nod,concat(' -s ',catFile($wrk,getRemoteSetup($nod)),\ ' -e RPT_DIRECTORY=',catFile($wrk,$nod),\ ',RPT_GROUP=',$RPT_GROUP,\ " -vdT 'diff:L:",$set,',',$nod,',',$num,':',$typ,':',$dir,"'")) return 'r' # Indicate a successful completion return 'T' } # Define the package transfer macro macro do_transfer {var ($nod,$rem,$set,$num) = @arg import $DIFF_FILE,$RPT_DIRECTORY,$RPT_GROUP if get($nod,catDir($rem,$nod,'sample'),\ sprintf($DIFF_FILE,$RPT_GROUP,$nod,$num,$set),\ catDir($RPT_DIRECTORY,'sample')) return 't' # Indicate a successful completion return '-' } #------------------------------------------------------------------------------ # Define the actions #------------------------------------------------------------------------------ # List available result sets macro do_list {import $RPT_DIRECTORY,$RPT_GROUP echo "\012Available Result Sets:" var $pat = concat('^',$RPT_GROUP,'_DIFF_[A-Z0-9]+_\d+_(\w*)\.txt$') var $lst = '' loop $fil (grepDir(catDir($RPT_DIRECTORY,'sample'),\ concat('^',$RPT_GROUP,'_DIFF_'),'in')) {var ($set) = match($fil,$pat,true) if compare('ne',$set,$lst) {echo "- Set '",$set,"':" var $lst = $set } echo ' ',$fil } if !$lst echo ' No sets found' } # Perform a remote collection macro do_request {var ($set,$num,$typ,$dir) = @arg import $RDA_WORK # Initialization if !getSetting('REMOTE_NODES') {echo 'No remote collection defined' return } var @nod = split(',',last) # Recover step information for aborted sessions if initSteps(true) call endSteps() # Check if there are pending remote requests loop $nod (@nod) {if isRemote($nod) {call initRemote() break } } # Perform the data collection in separate threads loop $nod (@nod) {call setTempSetting(concat('REMOTE_',$nod,'_STEP'),'N') thread {if(match(getStep($nod,'N'),'-')) var $stp = 'N' else var $stp = getStep($nod,'N') var $top = get_node($nod,'_HOME','.') var $wrk = get_node($nod,'_WORK',$RDA_WORK) # Detect the storage type of the remote node if compare('eq',$stp,'N') {debug $nod,': Detecting storage type' var $stp = setStep($nod,get_storage($nod,$RDA_WORK,$wrk)) } # Install the software on the remote node if compare('eq',$stp,'I') {debug $nod,': Installing RDA software' var $stp = setStep($nod,do_install($nod,$top)) } # Execute remotely RDA command if compare('eq',$stp,'R') {debug $nod,': Running RDA command' var $stp = setStep($nod,do_run($nod,$wrk,$set,$num,$typ,$dir)) } # Transfer the report package if compare('eq',$stp,'T') {debug $nod,': Transfering report package' var $stp = setStep($nod,do_transfer($nod,$wrk,$set,$num)) } } } wait call endSteps() } #------------------------------------------------------------------------------ # Main program #------------------------------------------------------------------------------ echo tput('bold'),'Comparing systems ...',tput('off') # Force the creation of the local sample directory call purge('S','DIFF\.tmp',0,0,true) # Execute the request call setAbbr('DIFF') if getSetting('TST_ARGS') {var ($opt,$set,@arg) = split(':',last) if compare('eq',$opt,'A') {var ($set,$num) = split(',',$set) if !match($set,$RE_SET) die 'Missing set' call do_request($set,$num,@arg) } elsif compare('eq',$opt,'C') {var ($nod,$num) = split(',',$arg[0]) var $fil1 = sprintf($DIFF_FILE,\ $RPT_GROUP,nvl($nod,'NOD001'),nvl($num,0),$set) var ($nod,$num) = split(',',$arg[1]) var $fil2 = sprintf($DIFF_FILE,\ $RPT_GROUP,nvl($nod,'NOD001'),nvl($num,0),$set) run DIFFcmp($fil1,$fil2) } elsif compare('eq',$opt,'D') call do_list() elsif or(compare('eq',$opt,'B'),compare('eq',$opt,'L')) {var ($set,$nod,$num) = split(',',$set) if !match($set,$RE_SET) die 'Missing set' run DIFFget(sprintf($DIFF_FILE,\ $RPT_GROUP,nvl($nod,'NOD001'),nvl($num,0),$set),\ $set,@arg) } } else {call requestSetting('TLdiff') var $opt = getSetting('DIFF_MENU') var $set = getSetting('DIFF_SET') if compare('eq',$opt,'A') call do_request($set,getSetting('DIFF_NUM'),\ getSetting('DIFF_TYPE'),\ getSetting('DIFF_DIR')) elsif compare('eq',$opt,'C') {if match($set,$RE_SET) run DIFFcmp(\ sprintf($DIFF_FILE,\ $RPT_GROUP,getSetting('DIFF_NOD1'),getSetting('DIFF_NUM1'),$set),\ sprintf($DIFF_FILE,\ $RPT_GROUP,getSetting('DIFF_NOD2'),getSetting('DIFF_NUM2'),$set)) else echo 'No set' } elsif compare('eq',$opt,'D') call do_list() elsif compare('eq',$opt,'L') run DIFFget(sprintf($DIFF_FILE,\ $RPT_GROUP,'NOD000',getSetting('DIFF_NUM'),$set),\ $set,getSetting('DIFF_TYPE'),getSetting('DIFF_DIR')) } =head1 SEE ALSO See also L, L. =begin credits =over 10 =item RDA 4.10: Michel Villette. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002-2008, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut