# DCconfig.ctl:010:Collects Key Configuration Information # $Id: DCconfig.ctl,v 1.20 2015/11/23 12:57:31 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/RDA/DCconfig.ctl,v 1.20 2015/11/23 12:57:31 RDA Exp $ # # Change History # 20151123 KRA Fix 'Database Information' report. =head1 NAME RDA:DCconfig - Collects Key Configuration Information =head1 DESCRIPTION This module performs the gathering of key configuration information for the RDA process. The following reports can be generated and are regrouped under C: =cut use Limit echo tput('bold'),'Processing RDA.CONFIG module ...',tput('off') if !isFiltered() toc '0:Executed on ',${RDA.T_HOST} # Initialization var $ORACLE_HOME = ${GRP.BEGIN.D_ORACLE_HOME} var $INTERIM = ${B_INTERIM} var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' toc '1:Overview' # Load the common macros run RDA:INVinfo() # Define the time limits var $mod = setLimit(${W_LIMIT}) call clearTiming() if compare('EQ',$mod,'P') call setPeriod(${T_START_TIME},${T_END_TIME},true) elsif compare('EQ',$mod,'E') call setInterval(${T_EVENT_TIME},${T_BEGIN_OFFSET},${T_END_OFFSET},\ ${T_REFERENCE},true) =head2 report - Report Settings Produces an overview of the main current settings, as well as some statistics about the SQL statement executions. This report contains basic run-time information only. You can find all gathered data by using the links in the index frame. The END module generates the report. =cut toc '2:[[',getFile('report','RDA.END',true),'][rda_report][Report Settings]]' =head2 system - System Information Produces an overview of key system configuration information (for example, CPUs and memory). The END module generates the report. =cut toc '2:[[',getFile('system','RDA.END'),'][rda_report][System Information]]' =head2 target - Target Information Produces an overview of the defined targets. The END module generates the report. =cut toc '2:[[',getFile('target','RDA.END'),'][rda_report][Target Information]]' =head2 catalog - Collected Files Produces an overview of the collected files, with an indication about the modules that collect them. The END module generates the report itself. =cut if !isFiltered() toc '2:[[',getFile('files','RDA.END',true),'][rda_report][Collected Files]]' =begin sections =head1 SECTION db This section can generate the following report: =end sections =cut section db =head2 database - Database Information When the database is installed, it gets the product versions and determines which version of the database is installed. Next, it gets additional information about the database from C, C. Finally, it executes a F and collects connection characteristics. The F command execution is limited to 30 seconds. =cut if ${SET.DB.DB.I_DB} {# Set the database context call setCurrent($cur = last) # Determine the database version debug ' Inside CONFIG module, identifying the database version' run DB:DBinfo() if get_db_version() var $DATABASE_VERSION = last # Prepare the report debug ' Inside CONFIG module, gathering key database information' report database var $TTL = '---+!! Database Information' var @TTL = ('',\ '---+ Database Overview',\ '---+ V$Database',\ '---+ V$Version') var @HDR = ('',\ undef,\ undef,\ '|*Banner*|') set $sql {PROMPT ___Capture_DB___ "SELECT '|*DB Name*|' || " d.name || ' |' || CHR(10) || " '|*Global Name*|' || " g.global_name || ' |' || CHR(10) || " '|*Host Name*|' || " i.host_name || ' |' || CHR(10) || " '|*Instance Name*|' || " i.instance_name || ' |' || CHR(10) || " '|*Instance Start Time*|' || " TO_CHAR(i.startup_time,'DD-Mon-YYYY HH24:MI:SS') || ' |' || CHR(10) || " '|*Restricted Mode*|' || " DECODE(i.logins,'RESTRICTED','YES','NO') || ' |' || CHR(10) || " '|*Archive Log Mode*|' || " d.log_mode || ' |' " FROM v$database d, v$instance i, global_name g; "PROMPT ___End_Capture___ "PROMPT ___Macro_separator(2)___ } if match($DATABASE_VERSION,'^7') {var $HDR[2] = '|*Name*|*Date Created*|*Log Mode*|' append $sql {SELECT '|' || " d.name || '|' || " d.created || '|' || " d.log_mode || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,'^80$') {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|' append $sql {SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,"^81$") {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|*Open Mode*|' append $sql {SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' || " d.open_mode || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,"^90$") {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|*Open Mode*|*Database Role*|' append $sql {SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' || " d.open_mode || '|' || " d.database_role || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,'^92$') {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|*Open Mode*|*Database Role*|*Force Logging*|' append $sql {SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' || " d.open_mode || '|' || " d.database_role || '|' || " d.force_logging || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,'^(10|11)') {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|*Open Mode*|*Database Role*|*Force Logging*|\ *Platform ID*|' append $sql {SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' || " d.open_mode || '|' || " d.database_role || '|' || " d.force_logging || '| ' || " d.platform_id || '|' " FROM v$database d; } } elsif match($DATABASE_VERSION,'^12') {var $HDR[2] = '|*DBID*|*Name*|*Date Created*|*Log Mode*|*ControlFile Type*|\ *Open ResetLogs*|*Open Mode*|*Database Role*|*Force Logging*|\ *Platform ID*|*CDB*|' append $sql {PROMPT ___Capture_CDB___ "SELECT '|' || " d.dbid || '|' || " d.name || '|' || " TO_CHAR(d.created, 'DD-Mon-YYYY HH24:MI:SS') || '|' || " d.log_mode || '|' || " d.controlfile_type || '|' || " d.open_resetlogs || '|' || " d.open_mode || '|' || " d.database_role || '|' || " d.force_logging || '| ' || " d.platform_id || '|' || " d.cdb || '|' " FROM v$database d; "PROMPT ___End_Capture___ } } call separator(1) call writeSql($sql) call separator(3) call writeLastSql() call separator(0,'Database Information') if ?$tgt = ${SET.DB.DB.I_DATABASE/P} {if ?grepSqlBuffer('CDB','\|YES \|\s*$','f') call $tgt->set_value('B_CDB',1,'Is a container database?') if ?grepSqlBuffer('DB','\|\*DB Name\*\|(.*) \|','f1') call $tgt->set_value('T_DB_NAME',last,'Database name') if ?grepSqlBuffer('DB','\|\*Instance Name\*\|(.*) \|','f1') call $tgt->set_value('T_INSTANCE_NAME',last,'Instance name') if get_db_full_version() call $tgt->set_value('V_BANNER',last,'Database version') } var $ORACLE_SID = ${SET.DB.DB.T_ORACLE_SID/P} if match(checkSid($ORACLE_SID,'',true),'^([^:]*):(\d+):([^:]*)(:(.*))?$') {var ($hst,$prt,$sid,undef,$svc) = (last) debug ' Inside CONFIG module, extracting database connection information' write '---+ Database Connection Information' write '|*Host*|',$hst,'|' write '|*Port*|',$prt,'|' if ?$svc {if length($sid) write '|*Instance Name*|',$sid,'|' write '|*Service Name*|',$svc,'|' } else write '|*System Identifier*|',$sid,'|' write $TOP } elsif ?nvl(findCommand('tnsping'),\ findCommand('tnsping',false,catDir($ORACLE_HOME,'bin'))) {var $cmd = last debug ' Inside CONFIG module, executing a tnsping' call loadCommand([$cmd,quote($ORACLE_SID)]) prefix write '---+ TNS Ping Information' var ($lin) = grepLastFile('Attempting to contact','i',-1) if $lin {if match($lin,'\(HOST\s*=\s*([^\)]+)\)',true) write '|*Host*|',last,'|' if match($lin,'\(PORT\s*=\s*([^\)]+)\)',true) write '|*Port*|',last,'|' if match($lin,'\(SERVICE_NAME\s*=\s*([^\)]+)\)',true) write '|*Service Name*|',last,'|' } var ($lin) = grepLastFile('OK\s*\(','i',-1) if $lin {if match($lin,'OK\s*\(([^\)]+)\)',true) write '|*Ping Time*|',last,'|' } if hasOutput(true) write $TOP } } =begin sections =head1 SECTION central This section can generate the following report: =end sections =cut section central =head2 homes - Oracle Home List Lists Oracle homes from central inventory. =cut if or(isWindows(),isCygwin()) var $inv = getRegValue('HKLM\SOFTWARE\Oracle','inst_loc') elsif isUnix() {var $loc = nvl(testFile('e','/etc/oraInst.loc'),\ testFile('e','/var/opt/oracle/oraInst.loc'),\ testFile('e',catFile($ORACLE_HOME,'oraInst.loc')),\ '') var $inv = value(grepFile($loc,'^[^\#]*inventory_loc','if')) } elsif isVms() {macro f_getsyi {var ($val) = command(concat('write sys$output f$getsyi("',$arg[0],'")')) return $val } var $hom = getEnv('SYS$LOGIN') var $nod = f_getsyi('NODENAME') var $inv = '' loop $dir (catDir($ORACLE_HOME),\ catDir($hom,$nod),\ catDir($hom)) {if ?testFile('r',catFile($dir,'orainst.loc')) {var $loc = catFile($dir,'orainst.loc') var $inv = value(grepFile($loc,'^[^#]*inventory_loc','if')) break } } } else var $inv = '' if $inv {debug ' Inside CONFIG module, listing Oracle homes' report homes var $fil = catFile($inv,'ContentsXML','inventory.xml') var $xml = xmlLoadFile($fil) prefix {write '---+ Oracle Home List' write '---## Information Taken from ',encode($fil) write '|*Name*|*Location*|' } loop $itm (xmlFind($xml,'.../HOME_LIST/HOME')) write '|',xmlValue($itm,'NAME'),' |',xmlValue($itm,'LOC'),' |' if isCreated(true) {toc '2:[[',getFile(),'][rda_report][Oracle Home List]]' share 'OI_INV','Oracle Home List' } } =begin sections =head1 SECTION oh This section can generate the following report: =end sections =cut section oh =head2 oh_inv - Oracle Home Product Information Produces a detailed inventory report based on the Oracle Home inventory information. =cut debug ' Inside CONFIG module, getting Oracle home inventory (can take time)' report [1] oh_inv if or(isWindows(),isCygwin()) var $nam = 'nt.rgs' else var $nam = 'unix.rgs' if ?testFile('fr',catFile($ORACLE_HOME,'inventory','ContentsXML','comps.xml')) {prefix {write '---+!! Oracle Home Product Information' write '---## From ',encode($ORACLE_HOME),' ' write $TOC } call inventory_details(catDir($ORACLE_HOME,'inventory'),$INTERIM) } elsif loadFile(catFile($ORACLE_HOME,'orainst',$nam)) {prefix {write '---+!! Oracle Home Product Information' write $TOC write '---+ Installed Products' write '|*Name*|*Version*|' } var $flt = isFiltered() loop $lin (getLines()) {next !match($lin,'Product files loaded') var @tbl = split('"',$lin) write '|',$tbl[5],' |',\ cond($flt,replace($tbl[3],'\.','.',true),$tbl[3]),' |' } if hasOutput(true) write $TOP } if isCreated(true) {toc '2:[[',getFile(),'][rda_report][Oracle Home Product Information]]' share 'OH_INV','Current Oracle Home' } =begin sections =head1 SECTION ias This section can generate the following report: =end sections =cut section ias =head2 as_inv - Application Server Product Information In Oracle Application context, it produces a detailed inventory report based on the Application Server inventory information. =cut var $ias = getEnv('IAS_ORACLE_HOME') if and($ias,\ testFile('fr',catFile($ias,'inventory','ContentsXML','comps.xml'))) {debug ' Inside CONFIG module, getting Application Server inventory \ (can take time)' report [1] as_inv prefix {write '---+!! Application Server Product Information' write '---## From ',encode($ias),' ' write $TOC } call inventory_details(catDir($ias,'inventory'),$INTERIM) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Application Server Product Information]]' } section none =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L, L, L =begin credits =over 10 =item RDA 4.15: Grant Hayden. =item RDA 8.10: Sayed Muhammed Sha. =back =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