# DCbegin.ctl:000:Initializes the Data Collection # $Id: DCbegin.ctl,v 1.15 2015/08/28 07:36:10 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/RDA/DCbegin.ctl,v 1.15 2015/08/28 07:36:10 RDA Exp $ # # Change History # 20150828 MSC Improve database access checks. =head1 NAME RDA:DCbegin - Initializes the Data Collection =cut use Log echo ${RDA.T_LINE} echo 'RDA Data Collection Started ',${RDA.T_LOCALTIME} echo ${RDA.T_LINE} echo tput('bold'),'Processing RDA.BEGIN module ...',tput('off') # Load the common macros before calling any other libraries run RDA:library() =head1 DESCRIPTION This module does the following: =over 2 =item o Checks that the RDA engine code is not obsolete. =cut debug ' Inside BEGIN module, testing the RDA engine code build' call testRda() =item o Performs operating system-specific initialization. =cut run &{check(getOsName(),'aix', 'OS:OSaix',\ 'darwin', 'OS:OSdarwin',\ 'dec_osf', 'OS:OSosf',\ 'dynixptx', 'OS:OSptx',\ 'hpux', 'OS:OShpux',\ 'linux', 'OS:OSlinux',\ 'solaris', 'OS:OSsunos',\ cond(isCygwin(), 'OS:OSwin32',\ isUnix(), 'OS:OSunix',\ isVms(), 'OS:OSvms',\ isWindows(),'OS:OSwin32'))}('BEGIN') =item o Determines if output files can be produced. =cut debug ' Inside BEGIN module, testing the report directory' if testOutput() die last =item o Validates the module targets involved in the collection. =cut macro val_target {var ($tgt,$flg,$req) = @arg import @tgt,%tgt keep @tgt,%tgt if exists($tgt{$pth = $tgt->get_oid}) return cond($tgt{$pth},1,0) # Validate the target creation eval var $cur = addTarget($tgt) if $tgt{$pth} = error->[-1] {call push(@tgt,concat($pth,' - ',$tgt->get_first('T_TITLE'),'|',last)) return 1 } # Validate the target connectivity if $flg {var $cls = $tgt->get_first('W_CLASS') if match($cls,'^[DS]Q$') {call setDbTarget($cur) if and(isDbEnabled(),testDb(true)) {call push(@tgt,concat($pth,' - ',$tgt->get_first('T_TITLE'),'|',\ $tgt{$pth} = getDbMessage())) return 1 } } elsif match($cls,'^DOM$') {if testDomain($req,$tgt,true) {call push(@tgt,concat($pth,' - ',$tgt->get_first('T_TITLE'),'|',\ $tgt{$pth} = last)) return 1 } } } return 0 } debug ' Inside BEGIN module, testing the module targets' var (@bad,@tgt,%tgt,%LOGIN,%URL) = () if ${B_TARGETS} {# Load the macros for testing connection loop $pkg (getPackages('^PW.*\.ctl$')) run &{$pkg}() if !isImplemented('findDomains') {macro findDomains return () } if !isImplemented('testDomain') {macro testDomain return undef } # Analyze all modules present in the run queue loop $mod (getCollectQueue()) {var $err = 0 # Test the module target connectivity var $itm = ${STA.${VAR.mod}/I} if ?$itm->get_first('I_TGT') incr $err,val_target(last,true) # Test database connectivity var $itm = ${SET.${VAR.mod}/I} loop $nam ($itm->grep('^I_DB')) incr $err,val_target($itm->get_first($nam),true) # Test domain connectivity loop $req (findDomains($itm)) incr $err,val_target($req->get_first('I_DOMAIN'),true,$req) # Consolidate modules with errors if $err call push(@bad,$mod) } if @tgt {var @{RUN.DISPLAY.T_TGT} = @tgt var @{RUN.DISPLAY.K_BAD} = @bad die A,['Target validation issues:',[@tgt]] } } else {# Test the module target creation loop $mod (getCollectQueue()) {next !?${STA.${VAR.mod}.I_TGT} if val_target(last,false) call push(@bad,$mod) } if @tgt {var @{RUN.DISPLAY.T_TGT} = @tgt var @{RUN.DISPLAY.K_BAD} = @bad call displayText('BadTargets',false) die A,'Execution interrupted' } } =item o Determines if a database connection can be made. RDA performs this test only when the DB:DCdb module has been configured. When a problem is detected, all SQL requests are disabled, but the other data collections are still performed. =cut if $def = ${SET.DB.DB.I_DB} {call setSqlTarget(last) call getSqlInfo() debug ' Inside BEGIN module, testing the database access' macro check_sqlplus {var ($cmd,$env) = @arg if isVms() return testCommand(concat($cmd,' -V')) var $trc = ${COL.TRACE.N_TARGET} var $bkp = setContext($env,$trc) var $cmd = cond(isAbsolute($cmd),testCommand(concat(quote($cmd),' -V')),\ findCommand($cmd)) call restoreContext($bkp,$trc) return $cmd } var $tgt = getSqlTarget() if !check_sqlplus($tgt->get_sqlplus) {call $tgt->set_failures(-1) if !or(${CUR.B_NO_DIALOG},\ displayText('NoSqlplus',true)) die A,'Execution interrupted' } elsif isSqlEnabled() {debug ' Inside BEGIN module, testing the database connection' if testSql(true) {echo getSqlMessage() if !or(${CUR.B_NO_DIALOG},\ displayText('NoConnection',true,sid=>$def->get_first('T_ORACLE_SID'))) die A,'Execution interrupted' if testSql(true) {echo tput('reverse'),last,tput('off') var $msg = getSqlMessage() call log('RDA','RDA:DCbegin','DB',$msg) echo $msg } else echo ' Database is now running.' } } } =item o Launches parallel executions. =cut debug ' Inside BEGIN module, launching parallel executions' if forkModules() debug ' - ',join("\012 - ",last) =back =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L =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