# TLdiff.def: Compares two Systems # $Id: TLdiff.def,v 1.15 2009/02/06 18:22:54 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/TLdiff.def,v 1.15 2009/02/06 18:22:54 mschenke Exp $ # # Change History # 20090206 KRA Encode file names. =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 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. -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_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 #------------------------------------------------------------------------------ # Collect the data based of a specification file macro do_check {var ($pth,$nod,$num) = @arg import $DIFF_FILE,$RPT_DIRECTORY,$RPT_GROUP # 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', 'OH','S000INI', 'RAC','S400RAC') var %chk = ('ASM','ASM_IN_USE',\ 'DB', 'DATABASE_INSTALLED',\ 'OH', 'ORACLE_HOME',\ 'RAC','CLUSTER_IN_USE') if !$tbl{'typ'} var $tbl{'typ'} = 'ASM,DB,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_FILE,\ $tbl{'grp'},nvl($nod,'NOD001'),nvl($num,0),$tbl{'set'}) run DIFFget($rpt,$tbl{'set'},$tbl{'typ'},$tbl{'dir'}) echo "Transfer the ",catFile($RPT_DIRECTORY,'sample',$rpt)," file" if $tbl{'tgt'} echo "in the ",$tbl{'tgt'}," directory on ",nvl($tbl{'hst'},'localhost') } # List available result sets macro do_list {import $RPT_DIRECTORY,$RPT_GROUP echo "\012Available Result Sets:" var $cnt = 0 var $pat = concat('^',$RPT_GROUP,'_DIFF_[A-Z0-9]+_\d+_(\w*)\.txt$') loop $fil (grepDir(catDir($RPT_DIRECTORY,'sample'),\ concat('^',$RPT_GROUP,'_DIFF_'),'in')) {var ($set) = match($fil,$pat,true) var $tbl{$set} = join("\012",$tbl{$set},concat(' ',$fil)) incr $cnt } if $cnt {loop $set (keys(%tbl)) echo "- Set '",$set,"':\012",$tbl{$set} } else 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() } # Produce a specification file macro do_spec {var ($set,$nam,$typ,$dir) = @arg import $MACHINE_NAME,$RPT_DIRECTORY,$RPT_GROUP # Validate the arguments if !length($nam) var $nam = 'spec' # Produce the specification file output SN,$nam write 'dir=',encode($dir) write 'grp=',$RPT_GROUP write 'hst=',$MACHINE_NAME write 'set=',$set write 'tgt=',encode(catDir($RPT_DIRECTORY,'sample')) write 'typ=',$typ var $rpt = getFile('/') close # Display the instructions echo "1. Copy the specification file ",$rpt," on the systems\012 \ where the collection must be done." echo "2. Execute the following command:\012 \ -vdT diff:F:" echo "3. Transfer the result files in the ",dirname($rpt)," directory." echo "4. Perform the comparaisons you want" } #------------------------------------------------------------------------------ # 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) } 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 = 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,'E') {if match($set,$RE_SET) call do_spec($set,getSetting('DIFF_SPEC'),\ getSetting('DIFF_TYPE'),\ getSetting('DIFF_DIR')) else echo 'No set' } elsif compare('eq',$opt,'F') call do_check(getSetting('DIFF_SPEC'),\ getSetting('DIFF_NOD'),\ getSetting('DIFF_NUM')) 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 L, L. =begin credits =over 10 =item RDA 4.10: Michel Villette. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002-2009, 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