# S305ASBR.def: Collects Application Server Backup and Recovery Information # $Id: S305ASBR.def,v 1.3 2008/02/25 17:32:55 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/S305ASBR.def,v 1.3 2008/02/25 17:32:55 mschenke Exp $ # # Change History # 20080225 MSC Change the copyright notice. =head1 NAME S305ASBR - Collects Application Server Backup and Recovery Information. =head1 DESCRIPTION This module collects the Application Server backup and recovery-related information. The following reports can be generated and are regrouped under C: =cut echo tput('bold'),'Processing ASBR module ...',tput('off') # Initialization var $ORACLE_HOME = getSetting('ORACLE_HOME','') var $ASBR_DB_INFO = getSetting('ASBR_DB_INFO','') var $ASBR_HOME = catDir($ORACLE_HOME,'backup_restore') var $DCM_HOME = catDir($ORACLE_HOME,'dcm') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:AS Backup/Recovery' set $NOT_OWNER_STATEMENT {**Note:** " "The RDA was executed with an operating system user which is different from "the operating system user who installed the Oracle Application Server. " "Therefore, no information are available in this section. " } # Load the common macros run library() =head2 db_info - Database Information Gathers the Application Server backup and recovery information from the database. Depending on the database version, it can collect data from C, C, and C. =cut if $ASBR_DB_INFO {var $sid = getSetting('ASBR_SID') var $usr = uc(getSetting('ASBR_LOGIN','SYSTEM')) var $dba = getSetting('ASBR_SYSDBA') # Load the common macros run DBinfo() # Determine the user password if compare('eq',$usr,'/') var ($usr,$pwd) = ('','') elsif hasSqlPassword($usr,$sid) var $pwd = undef else var $pwd = askPassword(concat('Enter ',$usr,'@',$sid,' user password:')) # Change the database context var $old = setSqlLogin($usr,$pwd,$sid,$dba) var $try = setSqlFailure(0) # Test the database connection and collect the information if !testSql() {var $ver = get_db_version(true) debug ' Inside ASBR module, gathering database information' report db_info var $TTL = '---+!! Application Server Backup/Recovery Database Information' if match($ver,'^(10|11)') {var @TTL = ('',\ '---+ Database Information',\ '---+ Recovery File Destination',\ '---+ Flash Recovery Area Usage') var @HDR = ('',\ '|*Name*|*Log Mode*|*Open Mode*|*Flashback On*|', \ '|*Name*| *Space Limit*| *Space Used*| *Space Reclaimable*| \ *Number of Files*|',\ '|*File Type* | *Used(MiB)*| *Reclaimable(MiB)*| \ *Number of Files*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " open_mode || ' |' || " flashback_on || ' |' " FROM v$database; "PROMPT ___Macro_separator(2)___ "SELECT '|' || " name || ' |' || " space_limit || '| ' || " space_used || '| ' || " space_reclaimable || '| ' || " number_of_files || '| ' " FROM v$recovery_file_dest; } if match($ver,'^(102$|11)') {append $sql {PROMPT ___Macro_separator(3)___ "SELECT '|' || " f.file_type || ' | ' || " ROUND(r.space_used * f.percent_space_used / 104857600,1) || '| ' || " ROUND(r.space_reclaimable * f.percent_space_reclaimable / " 104857600,1) || '| ' || " f.number_of_files || '| ' " FROM v$recovery_file_dest r,v$flash_recovery_area_usage f; } } } elsif match($ver,'^(81|9)') {var @TTL = ('','---+ Database Information') var @HDR = ('','|*Name*|*Log Mode*|*Open Mode*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " open_mode || ' |' || " FROM v$database; } } elsif match($ver,'^(80|7)') {var @TTL = ('','---+ Database Information') var @HDR = ('','|*Name*|*Log Mode*|') set $sql {SELECT '|' || " name || ' |' || " log_mode || ' |' || " FROM v$database; } } if $sql {call separator(1) call writeSql($sql) call separator(0,'Database Information') } } # Restore the previous context call setSqlLogin($old) call setSqlFailure($try) } =head2 scripts - Backup Script Results Collects the backup list, instance backup list, and changed configuration files by executing backup and restore scripts. =cut debug ' Inside ASBR module, gathering backup/restore scripts results' report scripts prefix {write '---+!! Output of Backup Restore Scripts' write $TOC } var $pgm = catFile($ASBR_HOME,cond(isWindows(),'bkp_restore.bat',\ 'bkp_restore.sh')) if testFile('x',$pgm) {var %ttl = ('list_backups', '---+ Backup List',\ 'list_instance_backups','---+ Instance Backup List',\ 'list_changed_config', '---+ Changed Configuration Files') loop $opt ('list_backups','list_instance_backups','list_changed_config') {var $cmd = concat(lastCommand(),' -m ',$opt) write $ttl{$opt} write '---## Using: ',$cmd call writeCommand($cmd) write $TOP } } elsif testFile('f',$pgm) {write '** ',$pgm,' is not executable.**%BR%\ Permissions are as following:%BR%' call statFile('b',$pgm) } if isCreated() toc '2:[[',getFile(),'][rda_report][Backup Script Results]]' =head2 dcm_archives - DCM archives Collects the list of DCM archives. =cut if grepDir(catDir($ORACLE_HOME,'dcm','bin'),'^dcmctl(\.exe)?$','fip') {var ($dcm) = last # Define a macro do get dcmctl output macro get_dcmshell {var ($cmd,$cod,$msg) = @arg import $TOP var $err = getTemp('err') var $in = createTemp('in') call writeTemp('in',$cod) call writeTemp('in','exit') call closeTemp('in') write '---## Using in dcmctl shell: ',$cod call loadCommand(concat($cmd," shell <",quote($in,'x'),\ " 2>",quote($err,'x'))) var @tbl = getLines() if @tbl {write '' loop $lin (@tbl) write replace($lin,'dcmctl>\s*') write '' write $TOP } elsif $msg write $msg if testFile('s',$err) {write '**Exception from "',$cmd,'"**%BR%' call writeFile($err) } call unlinkTemp('in') call unlinkTemp('err') } # Produce the report debug ' Inside ASBR module, gathering DCM Archive files' report dcm_archives write '---+ DCM Archives' toc '2:[[',getFile(),'][rda_report][DCM Archives]]' var ($pgm) = (grepDir(catDir($ORACLE_HOME,'opmn','bin'),'^opmnctl(\.exe)?$',\ 'fip')) var $uid = getOwner(getToc(true)) var $own = getOwner($pgm) if compare('ne',$uid,$own) {echo tput('reverse'),'Warning:' echo '========' echo 'The RDA was started as userid: ',$uid echo 'Oracle Application Server was installed on your system using userid: ',\ nvl($own,'[not found]') echo 'The RDA script will continue, but it will skip some collections.',\ tput('off') write $NOT_OWNER_STATEMENT } elsif (grepCommand(concat(quote($pgm,'x'),' status process-type=dcm-daemon'),\ 'alive','if')) call get_dcmshell(quote($dcm,'x'),'listArchives','No Archives Found') else write '**Note:** DCM is not running' } =head2 Configuration Files Collects all files from the F directory. =cut debug ' Inside ASBR module, gathering configuration files' pretoc '2:Configuration Files' var $dir = catDir($ASBR_HOME,'config') if testDir('d',$dir) call sort_files(3,0,grepDir($dir,'.*','pn')) unpretoc =head2 Log Files Collects the log files. =cut debug ' Inside ASBR module, gathering log files' pretoc '2:Log Files' var ($lin) = grepFile(catFile($dir,'config.inp'),'^log_path=','f') var $dir = key($lin) if !$dir var $dir = catDir($ASBR_HOME,'logs') if testDir('d',$dir) call sort_files(3,0,grepDir($dir,'.*','pn')) unpretoc =head2 not_found - Not Found Used as a warning when no Application Server Backup Recovery information is found. =cut if !isTocCreated() {debug ' Inside ASBR module, no information found' report not_found write 'No Application Server Backup Recovery information was found. This \ does not mean there was necessarily a problem with RDA, but it should \ be investigated.' toc '2:[[',getFile(),'][rda_report][Not Found]]' } =begin credits =over 10 =item RDA 4.10: Daniel Mortimer. =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