# S130INST.def: Collects Oracle Installation Information # $Id: S130INST.def,v 1.36 2008/01/23 12:48:29 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/S130INST.def,v 1.36 2008/01/23 12:48:29 mschenke Exp $ # # Change History # 20080123 DEM LD_ASSUME_KERNEL set only when opatch not working. =head1 NAME S130INST - Collects Oracle Installation Information =head1 DESCRIPTION This module collects Oracle installation information. The following reports can be generated and are regrouped under C: =cut echo tput('bold'),'Processing Oracle installation module ...',tput('off') # Initialization var $ORACLE_HOME = getSetting('ORACLE_HOME','') var $OPATCH_DIR = getSetting('OPATCH_DIR','') var $ORACLE_SID = nvl(field(':',-1,getSetting('ORACLE_SID')),'') var $INST_AGE = getSetting('INST_AGE',15) var $INST_FILTER = cond(isVms(),false,getSetting('INST_FILTER')) var $INST_TAIL = getSetting('INST_TAIL',1000) var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' toc '1:Oracle Installation' # Load the common macros run library() =head2 registry - Registry Settings On Windows, it exports the Oracle registry settings. =cut if isWindows() {debug ' Inside INST module, export Oracle registry settings' report registry write '---+!! Oracle Registry Settings' write $TOC if !writeRegistry('HKLM\Software\Oracle') write 'There are no Oracle registry entries' toc '2:[[',getFile(),'][rda_report][Registry Settings]]' } =head2 oratab - Oratab On UNIX, it reports F file content. =cut if isUnix() {debug ' Inside INST module, looking for an oratab file' report oratab loop $fil ('/var/opt/oracle/oratab','/etc/oratab') {if testFile('r',$fil) {write '---+!! Oratab File Content' write '---## From ',$fil write '' loop $lin (grepFile($fil,'^\s*($|#)','v')) write $lin write '' break } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Oratab]]' } =head2 oracle_home - Oracle Home Files Reports the content of key C directories. =cut debug ' Inside INST module, list files from primary $ORACLE_HOME directories' report oracle_home write '---+!! List Files from Primary $ORACLE_HOME Directories' write $TOC macro stat_dir0 {var ($dir) = @arg if testDir('d',$dir) call stat_dir1($dir) } macro stat_dir1 {var ($dir) = @arg import $TOP write '---+ Listing of ',$dir if !statDir('n',$dir) write 'Could not list files in ',$dir,'%BR%' write $TOP } call stat_dir1($ORACLE_HOME) call stat_dir1(catDir($ORACLE_HOME,'bin')) call stat_dir1(catDir($ORACLE_HOME,'lib')) call stat_dir0(catDir($ORACLE_HOME,'lib64')) call stat_dir1(catDir($ORACLE_HOME,'rdbms','lib')) call stat_dir0(catDir($ORACLE_HOME,'rdbms','lib64')) call stat_dir0(catDir($ORACLE_HOME,'lib32')) call stat_dir0(catDir($ORACLE_HOME,'rdbms','lib32')) call stat_dir0(getEnv('ORA_SQLLIB')) call stat_dir0(getEnv('ORA_JAVAVM_LIB')) call stat_dir0(getEnv('ORA_SQLJ_LIB')) call stat_dir0(catDir($ORACLE_HOME,'database')) call stat_dir0(catDir($ORACLE_HOME,'dbs')) toc '2:[[',getFile(),'][rda_report][Oracle Home Files]]' =head2 logicals - VMS Logicals On VMS, it reports the C, C, C<*PQL*> logicals and the database logical name tables. =cut if isVms() {debug ' Inside INST module, about to list VMS logicals for Oracle Server' report logicals write '---+!! VMS Logicals for Oracle Server' write $TOC write '---+ ORA* Logicals' call writeCommand('show logical ORA*') write $TOP write '---+ NLS_* Logicals' call writeCommand('show logical NLS_*') write $TOP write '---+ Database Logical Name Tables' call writeCommand('show logical/table=*ORA*') write $TOP write '---+ *PQL* Logicals' call writeCommand('show logical *PQL*') write $TOP toc '2:[[',getFile(),'][rda_report][VMS Logicals]]' =head2 identifiers - VMS Identifiers On VMS, it reports the C, C, C<*PQL*> logicals and the database logical name tables. =cut debug ' Inside INST module, about to list VMS identifiers' report identifiers var $TTL = '---+!! VMS Identifiers' prefix {if !isCreated() {write $TTL write $TOC } write '---+ Oracle Identifier' } var $pgm = createTemp('VMS','.com') call writeTemp('VMS','$ runuaf = "$SYS$SYSTEM:AUTHORIZE.EXE"') var $fil = 'ORA_ROOT:[000000]UTIL.DIR' if testFile('r',$fil) {var ($uic) = command(concat('write sys$output f$file_attribute("',$fil,\ '","UIC")')) call writeCommand(concat('runuaf show ',$uic,' /full')) call writeTemp('VMS',concat('$ runuaf show ',$uic,' /full')) } else call writeTemp('VMS','$ runuaf show *ORACLE* /full') call closeTemp('VMS') call writeCommand(concat('@',$pgm)) call unlinkTemp('VMS') if hasOutput(true) write $TOP prefix {if !isCreated() {write $TTL write $TOC } write '---+ List of all Identifiers' } var $pgm = createTemp('VMS','.com') call writeTemp('VMS','$ runuaf = "$SYS$SYSTEM:AUTHORIZE.EXE"') call writeTemp('VMS','$ runuaf show /identifier/full *') call closeTemp('VMS') call writeCommand(concat('@',$pgm)) call unlinkTemp('VMS') if hasOutput(true) write $TOP if isCreated() toc '2:[[',getFile(),'][rda_report][VMS Identifiers]]' } =head2 orainst_loc - oraInst.loc File On UNIX, it reads the F file to determine the directory where the inventory is stored. The F files should be in a logs directory directly underneath this. If the F file does not exist in any of three known possible locations, then a message is displayed informing you that the inventory was not found or else this is a pre-Oracle 8i installation. On Windows, the inventory directory is retrieved from the registry key C. =cut debug ' Inside INST module, about to do get installActions.log files' toc '2:Oracle Installer' if isWindows() var $inv = getRegValue('HKLM\Software\Oracle','inst_loc') elsif isUnix() {report orainst_loc write '---+ Contents of oraInst.loc file' if testFile('e','/etc/oraInst.loc') var $loc = '/etc/oraInst.loc' elsif testFile('e','/var/opt/oracle/oraInst.loc') var $loc = '/var/opt/oracle/oraInst.loc' elsif testFile('e',catFile($ORACLE_HOME,'oraInst.loc')) var $loc = catFile($ORACLE_HOME,'oraInst.loc') else var $loc = '' if !$loc {# Could not find the oraInst.loc file write 'Unable to find oraInst.loc file%BR%\ Checked /etc, /var/opt/oracle and $ORACLE_HOME.%BR%\ Verify database version as oraInst.loc files only in use for 8i and \ above.' var $inv = '' } elsif writeFile($loc) {# Extract the inventory directory from the file var $inv = value(grepFile($loc,'^[^#]*inventory_loc','if')) if !$inv {write 'oraInst.loc file does not contain the Inventory Location directory' } } else {# Could not read the oraInst.loc file write 'Unable to read oraInst.loc file%BR%\ May be file permission problem.%BR%\ Permissions are:%BR%' call statFile('p',$loc) write 'User: ',id(),'%BR%' var $inv = '' } toc '3:[[',getFile(),'][rda_report][oraInst.loc File]]' } else var $inv = '' =head2 inventory_xml - inventory.xml File Collects the F file from the inventory directory. =cut if $inv {debug ' Inside INST module, gathering the inventory.xml file' report inventory_xml var $fil = catFile($inv,'ContentsXML','inventory.xml') prefix {write '---+ inventory.xml File' write '---## Information Taken from ',$fil } call writeFile($fil) if isCreated(true) toc '3:[[',getFile(),'][rda_report][inventory.xml File]]' =head2 comps_xml - comps.xml File Collects the F from the inventory directory. =cut debug ' Inside INST module, gathering the comps.xml file' report comps_xml var $fil = catFile($inv,'ContentsXML','comps.xml') prefix {write '---+ comps.xml File' write '---## Information Taken from ',$fil } call writeFile($fil) if isCreated(true) toc '3:[[',getFile(),'][rda_report][comps.xml File]]' =head2 orainventory_logdir - Inventory Log Directory Explores the inventory directory. =cut debug ' Inside INST module, exploring the inventory location directory' report orainventory_logdir write '---+ Oracle Inventory Log Directory' toc '3:[[',getFile(),\ '][rda_report][Inventory Log Directory]]' if !testDir('r',$inv) {# No access to the logs directory. Ensure the files all denote it. write 'Unable to display ',$inv,' directory.%BR%\ Could be permissions problem.%BR%\ Permissions are:%BR%' call statDir('n',$inv) write 'User: ',id(),'%BR%' } else {# List the content of the logs directory var $log = catDir($inv,'logs') call statDir('n',$log) =head2 orainventory_files - Inventory Log Files Reports the Oracle Inventory log files and the related error and out files. Only accessible files with some content are collected. =cut macro get_file {var ($dir,$nam) = @arg var $fil = catFile($dir,$nam) # Check if the file access and size if !and(testFile('r',$fil),getSize($fil)) return $nam # Get the installation file data $nam call writeData($fil) return concat('[[',getFile('.'),'][_blank][',$nam,']]') } macro check_ora_home {var ($dat,$ref,$flg) = @arg # Select the file if there no Oracle home associations if !existsData('inst',$dat) return true # Check for the current Oracle home loop $dir (getDataKeys('inst',$dat)) {if compare('eq',cond($flg,lc(catDir($dir)),catDir($dir)),$ref) return true } return false } # Identify the files loop $fil (grepDir($log,'\.(log|err|out)','i')) {if match($fil,'^installActions(.*)\.log$',true) {var ($dat) = (last) var $dat{$dat} = 1 var $log{$dat} = get_file($log,$fil) loop $lin (grepFile(catFile($log,$fil),\ "Setting (variable 'ORACLE_HOME'|value of ORACLE_HOME) to ",'i')) {if match($lin,"\sto\s+'([^']+)'") call incrDataValue('inst',$dat,last) elsif match($lin,"\sto\s+([^'].*)") call incrDataValue('inst',$dat,last) } } elsif match($fil,'^oraInstall(.*)\.err$',true) {var ($dat) = (last) var $dat{$dat} = 1 var $err{$dat} = get_file($log,$fil) } elsif match($fil,'^oraInstall(.*)\.out$',true) {var ($dat) = (last) var $dat{$dat} = 1 var $out{$dat} = get_file($log,$fil) } } # Report the files report orainventory_files if $INST_FILTER {prefix {write '---+!! Oracle Inventory Log Files' write ' * Log files associated to ``',$ORACLE_HOME,'``' write ' * Log files that cannot be associated to an Oracle Home' write '%BR%' write '|*Log File*|*Error File*|*Out File*|*Associated Oracle Home*|' } if isWindows() var ($dir,$flg) = (lc(catDir($ORACLE_HOME)),true) else var ($dir,$flg) = (catDir($ORACLE_HOME),false) loop $dat (keys(%dat)) {var @OH = getDataValue($OH,$dat) loop $cmp (@OH) {if check_ora_home($dat,$dir,$flg) write '|',$log{$dat},' |',$err{$dat},' |',$out{$dat},' |',\ join('%BR%',getDataKeys('inst',$dat)),' |' } } } else {prefix {write '---+!! Oracle Inventory Log Files' write '|*Log File*|*Error File*|*Out File*|*Associated Oracle Home*|' } loop $dat (keys(%dat)) write '|',$log{$dat},' |',$err{$dat},' |',$out{$dat},' |',\ join('%BR%',getDataKeys('inst',$dat)),' |' } if isCreated(true) {write 'Only accessible files with some content have been collected.' toc '3:[[',getFile(),'][rda_report][Inventory Log Files]]' } call clearData('inst') =head2 oui_loc - Oracle Installer Location When the F file is found, it indicates the Oracle Universal Installer location. =cut report oui_loc var $fil = catFile($inv,'oui.loc') prefix {write '---+!! Oracle Universal Installer Location' write '---## From ',$fil } call writeFile($fil) if isCreated(true) toc '3:[[',getFile(),'][rda_report][Oracle Installer Location]]' } } =head2 make_report - Last Make Log Looks for F and F. =cut debug ' Inside INST module, looking for install.log and make.log' report make_report prefix write '---+ Install.log' if testFile('fr',catFile($ORACLE_HOME,'orainst','install.log')) call writeFile(lastFile()) elsif and($inv,testFile('fr',catFile($inv,'install.log'))) call writeFile(lastFile()) unprefix write '---+ Make.log' if !writeFile(catFile($ORACLE_HOME,'install','make.log')) write 'Could not find the make.log file in $ORACLE_HOME/install or \ could not read.' toc '3:[[',getFile(),'][rda_report][Last Make Log]]' =head2 rdbms_patches - RDBMS Patches On VMS, it gets the list of RDBMS patches. =cut if isVms() {debug ' Inside INST module, about to do get patch information' report rdbms_patches write '---+ RDBMS Patches' call writeFile('ORA_ROOT:[PATCHES]PATCHES_HISTORY.TXT') toc '2:[[',getFile(),'][rda_report][RDBMS Patches]]' } =head2 opatch_detail - Current Oracle Home Produces a detailed inventory report. Determines if F exists in the C. If it does not exist, the possible reasons may be as follows: =over 2 =item o The directory specified in the setup is incorrect. =item o Opatch is not valid, that is, Oracle Server is pre-Oracle 9i R2. =back =head2 opatch_all - All Oracle Homes When OPatch is available, it gives an overview of all Oracle homes. =cut else {debug ' Inside INST module, about to do get opatch information' report opatch_detail toc '2:OPatch Inventory Reports' toc '3:[[',getFile(),'][rda_report][Current Oracle Home]]' write '---+ Detailed Inventory Report' var $flg = false if isWindows() {var ($pgm) = grepDir($OPATCH_DIR,'^opatch\.bat$','fip') var $arg = concat('-oh ',$ORACLE_HOME,' 2>&1') } else {var ($pgm) = grepDir($OPATCH_DIR,'^opatch$','fip') var $arg = concat('-invPtrLoc "',$loc,'" 2>&1') } if !$pgm {write 'Unable to find OPatch, in $OPATCH_DIR%BR%\ For more details on OPatch please check the following note 189489.1 \ on Metalink%BR%\ Title: Oracle9i Data Server Interim Patch Installation (OPatch)' } else {var $pgm = quote($pgm,'x') # Produce the detail report var $cmd = concat($pgm,' lsinventory -detail ',$arg) var $sta = writeCommand($cmd) if !$sta {# Take care that LD_ASSUME_KERNEL is set on Linux if match(getOsName(),'linux') {var $key = 'LD_ASSUME_KERNEL' if !defined(getEnv($key)) {call setEnv($key,'2.4.19') var $flg = true var $sta = writeCommand($cmd) } } } if !$sta write 'Unable to execute OPatch' # Produce the global report report opatch_all prefix write '---+ All Oracle Homes' call writeCommand(concat($pgm,' lsinventory -all')) if isCreated(true) toc '3:[[',getFile(),'][rda_report][All Oracle Homes]]' # Restore the environment variable if $flg call setEnv($key) } } =head2 oradim_log - Oradim Log File Reports the contents of the F file. =cut debug ' Inside INST module, about to do get oradim log file' report oradim_log var $fil = catFile($ORACLE_HOME,'database','oradim.log') prefix {write '---+ Oradim Log File' write '---## From ',$fil } call writeFile($fil) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Oradim Log File]]' =head2 oracle_install - Oracle Home Installation Files Lists the content of the Oracle home installation directories and collects the recent related files. =cut debug ' Inside INST module, list Oracle home installation files' report oracle_install write '---+!! Oracle Home Installation Directories' write $TOC call stat_dir0(catDir($ORACLE_HOME,'.patch_storage')) call stat_dir0(catDir($ORACLE_HOME,'assistants','dbma','logs')) call stat_dir0(catDir($ORACLE_HOME,'assistants','dbua','logs')) call stat_dir0(catDir($ORACLE_HOME,'cfgtoollogs','dbua',$ORACLE_SID,'upgrade')) call stat_dir0(catDir($ORACLE_HOME,'cfgtoollogs','dbua','logs')) call stat_dir0(catDir($ORACLE_HOME,'cfgtoollogs','opatch')) toc '2:[[',getFile(),'][rda_report][Oracle Home Installation Files]]' debug ' Inside INST module, getting Oracle home installation file content' var $opt = concat('pm',$INST_AGE) call sort_files(3,$INST_TAIL,\ grepDir(catDir($ORACLE_HOME,'.patch_storage'),'.',$opt),\ grepDir(catDir($ORACLE_HOME,'assistants','dbma','logs'),'.',$opt),\ grepDir(catDir($ORACLE_HOME,'assistants','dbua','logs'),'.',$opt),\ grepDir(catDir($ORACLE_HOME,'cfgtoollogs','dbua','logs'),'.',$opt),\ grepDir(catDir($ORACLE_HOME,'cfgtoollogs','dbua',$ORACLE_SID,'upgrade'),\ '.',$opt),\ grepDir(catDir($ORACLE_HOME,'cfgtoollogs','opatch'),'.',$opt)) =head1 SEE ALSO See also L. =begin credits =over 10 =item RDA 4.1: Raul de Diego Garcia. =item RDA 4.2: Noriyuki Kamei. =item RDA 4.3: Satyanarayana Garaga, John Peeken. =item RDA 4.10: Daniel Mortimer. =item RDA 4.11: Alain Richy. =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