# TLdiff.def: Compares two Systems # $Id: TLdiff.def,v 2.8 2012/01/03 13:34:48 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/TLdiff.def,v 2.8 2012/01/03 13:34:48 mschenke Exp $ # # Change History # 20120103 MSC Change the copyright notice. =head1 NAME TLdiff - Compares Two Systems =head1 DESCRIPTION This tool compares two systems or two samples from the same system. For remote collections: =over 4 =item * A remote collection setup must be performed before running this tool. Use a command similar to the following: -vX Remote setup_cluster / =item * Data is extracted remotely on all nodes and transferred back into the F subdirectory. Collected samples are regrouped in a result set. =back You can compare samples from the same result set only. 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. -vT diff:E:::[,...][:|...] Prepares a specification file for comparing independent systems. -vT diff:F:,: Verifies the prerequisites and performs a data collection based in a specification file. =back =cut # Initialisation var $DIFF_REPORT = '%s_%06d_%s' var $DIFF_FILE = '%s_DIFF_%s_%06d_%s.txt' var $ORACLE_HOME = ${ORACLE_HOME:getEnv('ORACLE_HOME','')} var $EPM_HOME = ${EPM_HOME:${ENV.EPM_ORACLE_HOME:${ENV.HYPERION_HOME:''}}} var $ORACLE_SID = ${ORACLE_SID:getEnv('ORACLE_SID','')} 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(${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 if rda($nod,concat(' -s ',catFile($wrk,getRemoteSetup($nod)),\ ' -e RPT_DIRECTORY=',catFile($wrk,$nod),\ ',RPT_GROUP=',${CUR.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 if get($nod,catDir($rem,$nod,'sample'),\ sprintf($DIFF_FILE,${CUR.GROUP},$nod,$num,$set),\ ${OUT.S}) return 't' # Indicate a successful completion return '-' } #------------------------------------------------------------------------------ # Define the actions #------------------------------------------------------------------------------ # Collect the data based of a specification file macro do_check {var ($pth,$nod,$num) = @arg import $DIFF_REPORT # Parse the specification file var %tbl = ('grp','RDA') loop $lin (grepFile($pth,'^\w+=')) var $tbl{key($lin)} = value($lin) if missing($tbl{'set'}) {echo 'Invalid specification file' return } # Check if some setup is required var %req = (ASM => 'S402ASM',\ DB => 'S200DB',\ EPM => 'S545EPM', \ EPMA => 'S545EPM',\ HFM => 'S545EPM',\ OH => 'S000INI',\ RAC => 'S400RAC') var %chk = (ASM => 'ASM_IN_USE',\ DB => 'DATABASE_INSTALLED',\ EPM => 'EPM_HOME',\ EPMA => 'EPM_HOME',\ HFM => 'EPM_HOME',\ OH => 'ORACLE_HOME',\ RAC => 'CLUSTER_IN_USE') if !$tbl{'typ'} var $tbl{'typ'} = 'ASM,DB,EPM,EPMA,HFM,OH,OS,RAC' loop $mod (split(',',$tbl{'typ'})) {if !or(missing($chk{$mod}),defined(getSetting($chk{$mod}))) var $mod{$req{$mod}} = 1 } if keys(%mod) {var @mod = last echo 'The collection requires to setup the ',join(', ',@mod),' module(s)' echo ' -S ',join(' ',@mod) return } # Execute the request var $rpt = sprintf($DIFF_REPORT,nvl($nod,'NOD001'),nvl($num,0),$tbl{'set'}) run DIFFget($rpt,$tbl{'set'},$tbl{'typ'},$tbl{'dir'}) echo 'Transfer the ',last,' file' if $tbl{'tgt'} echo 'in the ',$tbl{'tgt'},' directory on ',nvl($tbl{'hst'},'localhost') } # List available result sets macro do_list {echo '\012Available Result Sets:' var $cnt = 0 var $pat = concat('^',${CUR.PREFIX},'[A-Z0-9]+_\d+_(\w*)\.txt$') loop $fil (grepDir(${OUT.S},concat('^',${CUR.PREFIX}),'in')) {if match($fil,$pat,true) call push($tbl{last},$fil) incr $cnt } if $cnt {loop $set (keys(%tbl)) dump "- Set '",$set,"':\012 ",join("\012 ",@{$tbl{$set}}) } else echo ' No sets found' } # Perform a remote collection macro do_request {var ($set,$num,$typ,$dir) = @arg # Initialization if !${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',${GRP.D_CWD}) # 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,${GRP.D_CWD},$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() } # Produce a specification file macro do_spec {var ($set,$nam,$typ,$dir) = @arg # Validate the arguments if !length($nam) var $nam = 'spec' # Produce the specification file output S,$nam write 'dir=',encode($dir) write 'grp=',${CUR.GROUP} write 'hst=',${RDA.NODE} write 'set=',$set write 'tgt=',encode(${OUT.S}) write 'typ=',$typ var $rpt = getFile('/') close # Display the instructions echo '1. \001Copy the specification file ',$rpt,' on the systems where the \ collection must be done.' echo '2. \001Execute the following command:\ \012 -vdT diff:F:' echo '3. \001Transfer the result files in the ',dirname($rpt),' directory.' echo '4. \001Perform the comparaisons you want' } #------------------------------------------------------------------------------ # Main program #------------------------------------------------------------------------------ echo tput('bold'),'Comparing systems ...',tput('off') # Force the creation of the local sample directory call setAbbr('DIFF') call purge('S','DIFF\.tmp',0,0,true) # Execute the request if ${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') {if !match($set,$RE_SET) die 'Missing set' var ($nod,$num) = split(',',$arg[0]) var $fil1 = sprintf($DIFF_FILE,\ ${CUR.GROUP},nvl($nod,'NOD001'),nvl($num,0),$set) var ($nod,$num) = split(',',$arg[1]) var $fil2 = sprintf($DIFF_FILE,\ ${CUR.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_REPORT,nvl($nod,'NOD001'),nvl($num,0),$set),\ $set,@arg) } elsif compare('eq',$opt,'E') {if !match($set,$RE_SET) die 'Missing set' call do_spec($set,@arg) } elsif compare('eq',$opt,'F') {var ($nod,$num) = split(',',$set) call do_check(join(':',@arg),nvl($nod,'NOD999'),nvl($num,0)) } } else {call requestSetting('TLdiff') var $opt = ${DIFF_MENU} var $set = ${DIFF_SET} if compare('eq',$opt,'A') call do_request($set,${DIFF_NUM},${DIFF_TYPE},${DIFF_DIR}) elsif compare('eq',$opt,'C') {if match($set,$RE_SET) run DIFFcmp(\ sprintf($DIFF_FILE,\ ${CUR.GROUP},${DIFF_NOD1},${DIFF_NUM1},$set),\ sprintf($DIFF_FILE,\ ${CUR.GROUP},${DIFF_NOD2},${DIFF_NUM2},$set)) else echo 'No set' } elsif compare('eq',$opt,'D') call do_list() elsif compare('eq',$opt,'E') {if match($set,$RE_SET) call do_spec($set,${DIFF_SPEC},${DIFF_TYPE},${DIFF_DIR}) else echo 'No set' } elsif compare('eq',$opt,'F') call do_check(${DIFF_SPEC},${DIFF_NOD},${DIFF_NUM}) elsif compare('eq',$opt,'L') run DIFFget(sprintf($DIFF_REPORT,'NOD000',${DIFF_NUM},$set),\ $set,${DIFF_TYPE},${DIFF_DIR}) } =head1 SEE ALSO L, L. =begin credits =over 10 =item RDA 4.10: Michel Villette. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, 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