# CRSload.def: Collects CRS diagnostic collection tool results # $Id: CRSload.def,v 1.3 2009/05/25 17:30:56 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/CRSload.def,v 1.3 2009/05/25 17:30:56 mschenke Exp $ # # Change History # 20090525 KRA Improve option formation. =head1 NAME CRSload - Collects CRS Diagnostic Collection Tool Results =head1 DESCRIPTION =head2 crs_diag_tool - CRS Diagnostic Collection Tool This module executes the Cluster Ready Services (CRS) diagnostic collection tool and collects the produced files. =cut debug ' Inside LOAD module, running CRS diagnostic collection tool' # Remove old reports call purge('E','CRS_',0,0,true) # Check if CRS collection is disabled if !getSetting('CRS_LOAD') return # Check if Perl is available var $prl = getSetting('RDA_PERL') if !$prl return # Initialization var $ORACLE_HOME = getSetting('ORACLE_HOME',getEnv('ORACLE_HOME','')) var $ORA_CRS_HOME = getEnv('ORA_CRS_HOME','') var $RPT_DIRECTORY = getSetting('RPT_DIRECTORY','output') var $RPT_GROUP = getSetting('RPT_GROUP','RDA') # Determine ORA_CRS_HOME if !testDir('d',$ORA_CRS_HOME) {echo ' Warning: ORA_CRS_HOME environment variable is not set' var $osn = getOsName() if match($osn,'solaris') {if grepFile('/etc/init.d/init.cssd','^ORA_CRS_HOME=','f') var $ORA_CRS_HOME = value(last) } elsif match($osn,'hpux') {if grepFile('/sbin/init.d/init.cssd','^ORA_CRS_HOME=','f') var $ORA_CRS_HOME = value(last) } elsif match($osn,'aix') {if grepFile('/etc/init.cssd','^ORA_CRS_HOME=','f') var $ORA_CRS_HOME = value(last) } elsif match($osn,'dec_osf') {if grepFile('/sbin/init.d/init.cssd','^ORA_CRS_HOME=','f') var $ORA_CRS_HOME = value(last) } elsif match($osn,'linux') {if grepFile('/etc/init.d/init.cssd','^ORA_CRS_HOME=','f') var $ORA_CRS_HOME = value(last) } elsif isWindows() {var $CRS_KEY = 'HKLM\SYSTEM\CurrentControlSet\Services\OracleCRService' if match(getRegValue($CRS_KEY,'ImagePath'),'^(.*)\s+service\s*$',true) {var @tbl = splitDir(dirname(catFile(trim(last)))) var $tbl[-1] = curDir() var $ORA_CRS_HOME = catDir(@tbl) } } } if !testDir('d',$ORA_CRS_HOME) return # Run diacollection.pl var $fil = catFile($ORA_CRS_HOME,'bin','diagcollection.pl') if testFile('x',$fil) {var ($pgm,@opt) = (lastCommand()) var $dir = cond(isAbsolute($RPT_DIRECTORY),\ catDir($RPT_DIRECTORY,'extern'),\ catDir(getSetting('RDA_WORK'),$RPT_DIRECTORY,'extern')) # Determine the command options if !isWindows() {if grepFile($fil,'\[--nocore\]','fi') {if !getSetting('CRS_CORE',0) var @opt = ('--nocore') } elsif getSetting('CRS_CORE',0) var @opt = ('--core') if grepFile($fil,'\[--afterdate\]','fi') {if match(getSetting('CRS_AFTER'),'^([01]\d/[0-3]\d/\d{4})$') var @opt = (@opt,'--afterdate',last) } } if grepFile($fil,'\[--crshome\]','fi') var @opt = (@opt,'--crshome',$ORA_CRS_HOME) # Set the CRS environment var $env_crs = setEnv('ORA_CRS_HOME',$ORA_CRS_HOME) var $env_oh = setEnv('ORACLE_HOME',$ORACLE_HOME) # Generate the job and execute it if isWindows() {if compare('eq',getOsName(),'cygwin') {var $job = createTemp('CRS','.sh',true) call writeTemp('CRS','cd "',$dir,'"') call writeTemp('CRS',join(' ',quote($prl,'x'),$pgm,'--collect','--crs',@opt)) } else {var $job = createTemp('CRS','.bat',true) call writeTemp('CRS','@echo off') call writeTemp('CRS','cd /d "',$dir,'"') call writeTemp('CRS','"',$prl,'" ',$pgm,' --collect --crs ',join(' ',@opt)) } } elsif isVms() {var $job = createTemp('CRS','.com',true) call writeTemp('CRS','$ SET DEFAULT ',$dir) call writeTemp('CRS',join(' ','$','perl',$pgm,'--collect','--crs',@opt)) } else {var $job = createTemp('CRS','.sh',true) call writeTemp('CRS','cd "',$dir,'"') call writeTemp('CRS',join(' ',quote($prl,'x'),$pgm,'--collect','--crs',@opt)) } call closeTemp('CRS') call command(quote($job,'x')) call unlinkTemp('CRS') # Restore the previous environment call setEnv('ORA_CRS_HOME',$env_crs) call setEnv('ORACLE_HOME', $env_oh) # Rename the produced files and generate the report report crs_diag_tool prefix {write '---+ Cluster Ready Services (CRS) Diagnostic Collection Tool Results' write '|*File Name*|*Last Modified Date*| *Size*|' } loop $src (grepDir($dir,'^(core|crs|ocr|ora)Data.*\.(gz|zip)$','in')) {var ($nam,$ext) = match($src,'^(core|crs|ocr|ora)Data.*\.(gz|zip)$','i') var $dst = concat($RPT_GROUP,'_CRS_',$nam,'.',$ext) if transfer($dir,$src,$dir,$dst) {var $fil = catFile($dir,$dst) write '|[[extern/',$dst,'][_blank][',encode($src),']]|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),'| ',\ getSize($fil),'|' } } if isCreated(true) {write ' * Links point to files that have been collected in their original \ format. Opening them directly in your browser can present risks. \ To prevent them, access the file outside the browser or use \ the link to save them and use an adequate viewer.' toc '2:[[',getFile(),'][rda_report][CRS Diagnostic Collection Tool]]' } } =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