# S204LOG.def: Collects RDBMS Log and Trace Files # $Id: S204LOG.def,v 1.27 2008/02/25 13:29:24 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/S204LOG.def,v 1.27 2008/02/25 13:29:24 mschenke Exp $ # # Change History # 20080225 MSC Improve the documentation. =head1 NAME S204LOG - Collects RDBMS Log and Trace Files =head1 DESCRIPTION This module collects the RDBMS log and trace files. This is performed only for databases associated with the current Oracle home. The following reports can be generated and are regrouped in C: =cut if !getSetting('DATABASE_LOCAL') return echo tput('bold'),'Processing LOG module ...',tput('off') # Initialization var $MACHINE_NAME = getSetting('MACHINE_NAME') var $ORACLE_HOME = getSetting('ORACLE_HOME') var $ORACLE_SID = field(':',-1,getSetting('ORACLE_SID','')) var $ALERT_SUMMARY = getSetting('ALERT_SUMMARY') var $ALERT_TAIL = getSetting('ALERT_TAIL',30000) var $LOG_AGE = getSetting('DB_TRACE_AGE',15) var $LOG_ERRORS = max(1,getSetting('DB_TRACE_ERRORS',250)) var $LOG_TRESHOLD = getSetting('DB_TRACE_TRESHOLD',20480) var $LOG_RATIO = max(1,getSetting('DB_TRACE_RATIO',10)) var $LOG_VOLUME = getSetting('DB_TRACE_VOLUME',10) var $BDUMP_MAX = getSetting('DB_TRACE_BDUMP',2) var $BDUMP_VOLUME = getSetting('DB_TRACE_BVOLUME',100) var $UDUMP_AGE = getSetting('DB_TRACE_UDUMP',0) var $UDUMP_DG = getSetting('DB_TRACE_DG',0) var $UDUMP_VOLUME = getSetting('DB_TRACE_UVOLUME',10) var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' toc '1:RDBMS Log/Trace Files' # Load the common macros run library() run DBalert() run DBinfo() # Get the dump destinations var $BDUMP_DIR = get_bdump() var $CDUMP_DIR = get_cdump() var $UDUMP_DIR = get_udump() var $DIAG_DIR = find_diag() var $TRACE_DIR = cond($DIAG_DIR,catDir($DIAG_DIR,'trace'),$BDUMP_DIR) # Define a macro to estimate the size after compression macro get_size {var ($fil) = @arg import $LOG_RATIO,$LOG_TRESHOLD keep $LOG_RATIO,$LOG_TRESHOLD var $siz = getSize($fil) if expr('>',$siz,$LOG_TRESHOLD) var $siz = expr('/',$siz,$LOG_RATIO) return $siz } =head2 alert_log - Alert.log Displays the content of the alert log. By default, it is limited to the last 30000 lines, but the number of lines can be increased to include the last start. =head2 alert_sum - Alert.log Analysis When requested, RDA analyzes the lines extracted from the alert log and produces a summary (not available for 11g). =cut var @err = () macro push_err {var (\@err,$lin,$max) = @arg if expr('<',scalar(@err),$max) var @err = (@err,$lin) else var (undef,@err) = (@err,$lin) return -1 } if $DIAG_DIR {debug ' Inside LOG module, found diagdir ',$DIAG_DIR,', get log info' var $fil = catFile($DIAG_DIR,'alert','log.xml') if createBuffer('ALR','R',$fil) {# Parse the alert log for errors and last startup var $lst = undef call parseVar($lin) call parsePattern('TOP',\ '^',$lst,$min) var $lst = undef } if $lst {var $cnt = expr('-',$max,$lst) incr $cnt call setPos('ALR',$pos) } else {call setPos('ALR') while getLine('ALR',$min) {var $lin = chomp(last) break match($lin,'^',$num,0) {debug ' Inside LOG module, getting additional alert.log files' report more_alerts prefix {write '---+ Additional Alert Log Files' write '|*File Name*| *Size*|*Last Modification*|' } suspend report var $cnt = 0 loop $fil (split('\|',getSetting('ALERT_FILE_PATTERN'))) {var $fil = catFile($fil) var ($max,$dir,$nam) = ($num,dirname($fil),basename($fil)) loop $pth (grepDir($dir,concat(quote($nam),'.*'),'pt')) {next !testFile('fr',$pth) incr $cnt data concat('alert',$cnt) if writeData($pth) {var $rpt = getFile('.') resume report write '|[[',$rpt,'][_blank][',$pth,']]| ',getSize($pth),'|',\ getLastModify($pth,'%d-%b-%Y %H:%M:%S'),' |' suspend report if !match($pth,'\.zip$',true) var $fil{$pth} = getLastModify($pth) decr $max break !$max } } } resume report if hasOutput(true) toc '2:[[',getFile(),'][rda_report][Additional Alert Log Files]]' # Check if the errors to be collected are not greater than the maximum loop $fil (keys(%fil,'ND')) {var $max = $LOG_ERRORS decr $max,scalar(@err) if expr('<=',$max,0) break if $DIAG_DIR {# Treat 11G if createBuffer('ALR','R',$fil) {# Parse the alert log for errors var @new = () call parseReset() call parseVar($lin) call parsePattern('TOP',\ '(Errors in file|Details in trace file)',push_err(\@new,$lin,$max)) call parse('ALR') var @err = (@new,@err) call deleteBuffer('ALR') } } elsif $BDUMP_DIR {# Treat pre 11G var @err = (\ grepFile($fil,'(Errors in file|Details in trace file)',expr('-',0,$max)),\ @err) } } } if @err {# Determine the size of the alert.log report var $tot = get_size(catFile(getSetting('RPT_DIRECTORY'),getFile('.'))) # Analyze the last errors var $flg = true var $vol = expr('*',$LOG_VOLUME,1048576) loop $lin (reverse(@err)) {# Get the file name if match($lin,'Errors in file\s+(.*)$') var $fil = trim(last,':') elsif match($lin,'Details in trace file\s+(.*)$') var $fil = trim(last,':') else next # Eliminate missing, duplicate, and old files next !$fil next exists($tbl{$fil}) var $tbl{$fil} = 1 # Get the file contribution if and($flg,testFile('r',$fil),isNewer($fil,$LOG_AGE)) {incr $tot,get_size($fil) if expr('<',$tot,$vol) {var @col = (@col,$fil) next } var $flag = false } var @exc = (@exc,$fil) } =head2 last_errors - Last Errors The alert log is also scanned to retrieve the trace files associated with errors. To limit the data collection volume, only the latest trace files are collected based on their last modification date and the total volume. =cut debug ' Inside LOG module, retrieving last errors' report last_errors macro add_title {if !isCreated(true) {import $TOC,$LOG_AGE,$LOG_ERRORS,$LOG_VOLUME write '---+!!Trace Files Related to Last Errors' write $TOC write '%BR%' write ' * Investigation limited to ',$LOG_ERRORS,' last errors' write ' * Trace files not older than ',$LOG_AGE,' days' write ' * Trace file volume lower than ',$LOG_VOLUME,\ ' MiB after compression' } } prefix {call add_title() write '---+ Collected Trace Files' write '|*Trace File*| *Size*|*Last Modification*|' } suspend report var $dir = cond(isWindows(),catDir($ORACLE_HOME,'database'),\ catDir($ORACLE_HOME,'dbs')) loop $fil (@col) {incr $cnt if !isAbsolute($fil) var $fil = catFile($dir,$fil) data concat('error',$cnt,'_',basename($fil)) if writeData($fil) {var $rpt = getFile('.') share 'log_error',$fil resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report } } resume report if hasOutput(true) write $TOP prefix {call add_title() write '---+ Other Trace Files' write 'Files not collected due to age, permissions problems or collected \ size constraints.' write '|*Trace File*| *Size*|*Last Modification*|' } loop $fil (@exc) {if !isAbsolute($fil) var $fil = catFile($dir,$fil) write '|',$fil,'| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' } if hasOutput(true) write $TOP if isCreated(true) toc '2:[[',getFile(),'][rda_report][Last Errors]]' # Get the share identifiers loop $id (findShares('log_error','LOG')) var $col{getShare($id)} = $id } =head2 log_trace - Trace/Log Directory Listings Lists the contents of trace/dump directories. =cut debug ' Inside LOG module, doing ls of Oracle trace/log directories' report log_trace write '---+!!Listing of Files from Oracle Log/Trace Directories' write $TOC var $NOT = '%BR%**Note:** The operating system can relocated the core files \ in another location. The ``/etc/coreadm.conf`` file can provide \ some extra information on that mechanism. The OS module collects \ that file. Run the OS module if needed.%BR%' if $DIAG_DIR {write '---+ Diagnostic Traces' if !statDir('at',catDir($DIAG_DIR,'trace')) write 'Could not list files in ',lastDir(),'%BR%' write $TOP write '---+ Incidents' if !statDir('at',catDir($DIAG_DIR,'incident')) write 'Could not list files in ',lastDir(),'%BR%' write $TOP write '---+ Incident Packages' if !statDir('at',catDir($DIAG_DIR,'incpkg')) write 'Could not list files in ',lastDir(),'%BR%' write $TOP write '---+ Core Dumps' if !statDir('at',catDir($DIAG_DIR,'cdump')) write 'Could not list files in ',lastDir(),'%BR%' if testFile('e','/etc/coreadm.conf') write $NOT write $TOP } write '---+ Background Dump Destination' if !$BDUMP_DIR write 'Background Dump destination could not be determined.%BR%' elsif !statDir('at',$BDUMP_DIR) write 'Could not list files in ',$BDUMP_DIR,'%BR%' write $TOP var $dir = catDir($ORACLE_HOME,'rdbms','log') if !sameDir($BDUMP_DIR,$dir) {write '---+ Default Background Dump Destination.%BR%' if !statDir('at',$dir) write 'Could not list files in ',$dir,'%BR%' write $TOP } if !$DIAG_DIR {write '---+ Core Dump Destination' if !$CDUMP_DIR write 'Core Dump destination could not be determined.%BR%' elsif !statDir('at',$CDUMP_DIR) write 'Could not list files in ',$CDUMP_DIR,'%BR%' if testFile('e','/etc/coreadm.conf') write $NOT write $TOP var $dir = cond(isWindows(),catDir($ORACLE_HOME,'database'),\ catDir($ORACLE_HOME,'dbs')) if !sameDir($CDUMP_DIR,$dir) {write '---+ Default Core Dump Destination' if !statDir('at',$dir) write 'Could not list files in ',$dir,'%BR%' write $TOP } } write '---+ User Dump Destination' if !$UDUMP_DIR write 'User Dump destination could not be determined.%BR%' elsif sameDir($UDUMP_DIR,$BDUMP_DIR) write 'User Dump destination and Background Dump destination are the same.\ %BR%Please see Background Dump destination for listing.%BR%' elsif !statDir('at',$UDUMP_DIR) write 'Could not list files in ',$UDUMP_DIR,'%BR%' write $TOP var $dir = catDir($ORACLE_HOME,'rdbms','trace') write '---+ RDBMS Trace Destination' if !statDir('at',$dir) write 'Could not list files in ',$dir,'%BR%' write $TOP toc '2:[[',getFile(),'][rda_report][Trace/Log Directory Listings]]' =head2 bdump - Recent Background Trace Files Collects the most recent trace files for each type of background process. Old files are not considered. =cut if and($TRACE_DIR,$BDUMP_MAX) {debug ' Inside LOG module, gathering most recent background trace files' report bdump macro add_btitle {if !isCreated(true) {import $TOC,$LOG_AGE,$BDUMP_MAX,$BDUMP_VOLUME write '---+!! Most Recent Background Trace Files' write $TOC write '%BR%' write ' * Background trace files not older than ',$LOG_AGE,' days' write ' * Limited to ',$BDUMP_MAX,' files of each type' write ' * File size lower than ',$BDUMP_VOLUME,' MiB' } } prefix {call add_btitle() write '---+ Collected Files' write '|*Type*|*Trace File*| *Size*|*Last Modification*|' } suspend report var $vol = expr('*',$BDUMP_VOLUME,1048576) var ($cnt,@tbl,%fil,%ref) = (0) loop $nam (grepDir($TRACE_DIR,\ concat('^',quote($ORACLE_SID),'_[^_\.]+_.*\.trc$'),\ concat('itm',$LOG_AGE))) {var $typ = field('_',1,$nam) incr $ref{$typ} next expr('>',$ref{$typ},$BDUMP_MAX) var $fil{$typ} = join("\012",$fil{$typ},$nam) } loop $typ (keys(%ref)) {loop $nam (split('\012',$fil{$typ})) {var $fil = catFile($TRACE_DIR,$nam) if expr('<',get_size($fil),$vol) {incr $cnt data concat('bdump',$cnt,'_',$nam) if writeData($fil) {var $rpt = getFile('.') if match($typ,'^(arch|dmon|lgwr|lsp|nsv|p0|rsm)',true) share 'dg_bdump',$fil resume report write '|',$typ,' |[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report next } } var @tbl = (@tbl,$fil) } } resume report if (@tbl) {call add_btitle() write '---+ Other Trace Files' write 'Files not collected due to permissions problems or size constraints.' write '|*Trace File*| *Size*|*Last Modification*|' loop $fil (@tbl) write '|',$fil,'| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' } if isCreated(true) toc '3:[[',getFile(),'][rda_report][Recent Background Trace Files]]' } =head2 udump - Recent User Dumps When requested, most recent user dumps can be collected. =cut if and($UDUMP_DIR,$UDUMP_AGE) {debug ' Inside LOG module, gathering most recent user dumps' report udump macro add_utitle {if !isCreated(true) {import $TOC,$UDUMP_AGE,$UDUMP_VOLUME write '---+!! Most Recent User Dumps' write $TOC write '%BR%' write ' * User dumps not older than ',$UDUMP_AGE,' days' write ' * User dump volume lower than ',$UDUMP_VOLUME,\ ' MiB after compression' } } prefix {call add_utitle() write '---+ Collected Files' write '|*User Dump*| *Size*|*Last Modification*|' } suspend report var $vol = expr('*',$UDUMP_VOLUME,1048576) var ($cnt,$tot,$flg,@tbl) = (0,0,true) loop $nam (grepDir($UDUMP_DIR,concat('^',quote($ORACLE_SID),'_.*\.trc$'),\ concat('itm',$UDUMP_AGE))) {var $fil = catFile($UDUMP_DIR,$nam) if exists($col{$fil}) {var $rpt = setShare($col{$fil},true) resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report next } elsif $flg {incr $tot,get_size($fil) if expr('<',$tot,$vol) {var @col = (@col,$fil) incr $cnt data concat('udump',$cnt,'_',$nam) if writeData($fil) {var $rpt = getFile('.') share 'log_udump',$fil resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report next } } else var $flg = false } var @tbl = (@tbl,$fil) } resume report if (@tbl) {call add_utitle() write '---+ Other Files' write 'Files not collected due to permissions problems or collected size \ constraints.' write '|*User Dump*| *Size*|*Last Modification*|' loop $fil (@tbl) write '|',$fil,'| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' } if isCreated(true) toc '3:[[',getFile(),'][rda_report][Recent User Dumps]]' # Get the share identifiers loop $id (findShares('log_udump','LOG')) var $col{getShare($id)} = $id } =head2 dg - Data Guard Broker Log Files Displays the Data Guard Broker-related log files. =cut if getSetting('DG_IN_USE') {debug ' Inside LOG module, gathering Data Guard broker log files' var $TTL = '---+!! Data Guard Broker Log Files' report dg prefix {if !isCreated() {write $TTL write $TOC } write '---+ Data Guard Broker Log' write '|*Trace File*| *Size*|*Last Modification*|' } suspend report loop $nam (grepDir($BDUMP_DIR,'^drc\w+\.log$','it')) {var $fil = catFile($BDUMP_DIR,$nam) incr $cnt data concat('drc',$cnt,'_',$nam) if writeData($fil) {var $rpt = getFile('.') resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report } } resume report if hasOutput(true) write $TOP prefix {if !isCreated() {write $TTL write $TOC } write '---+ Background Dump Destination Log Files' write ' * Background trace files not older than ',$LOG_AGE,' days' write ' * Limited to ',$BDUMP_MAX,' files of each type' write ' * File size lower than ',$BDUMP_VOLUME,' MiB' write '|*Type*|*Trace File*| *Size*|*Last Modification*|' } loop $id (findShares('dg_bdump','LOG')) {var $fil = getShare($id) var $typ = field('_',1,basename($fil)) var $rpt = setShare($id,true) write '|',$typ,'|[[',$rpt,'][_blank][',$fil,']]| ',\ getSize($fil),'|',getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' } if hasOutput(true) write $TOP prefix {if !isCreated() {write $TTL write $TOC } write '---+ User Dump Destination Log Files' write ' * User dumps not older than ',$UDUMP_DG,' days' write '|*Trace File*| *Size*|*Last Modification*|' } suspend report loop $nam (grepDir($UDUMP_DIR,\ concat('^',quote($ORACLE_SID),'_(drc|fal|rfs).*\.trc$'),\ concat('itm',$UDUMP_DG))) {var $fil = catFile($UDUMP_DIR,$nam) if exists($col{$fil}) {var $rpt = setShare($col{$fil},true) resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report } else {incr $cnt data concat('udump',$cnt,'_',$nam) if writeData($fil) {var $rpt = getFile('.') resume report write '|[[',$rpt,'][_blank][',$fil,']]| ',getSize($fil),'|',\ getLastModify($fil,'%d-%b-%Y %H:%M:%S'),' |' suspend report } } } resume report if hasOutput(true) write $TOP if isCreated(true) toc '2:[[',getFile(),'][rda_report][Data Guard Broker Log Files]]' } =head1 SEE ALSO See also L, L, L, L, L. =begin credits =over 10 =item RDA 4.1: Bob King, Fokke Zijlstra. =item RDA 4.3: Roger Snowden. =item RDA 4.6: Bob Caldwell. =item RDA 4.7: Brandie Smith. =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