# BRMr7.def: Collects Oracle Communication BRM 7.x Information # $Id: BRMr7.def,v 1.19 2009/02/06 18:22:53 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/BRMr7.def,v 1.19 2009/02/06 18:22:53 mschenke Exp $ # # Change History # 20090206 DEM Encode file names. =head1 NAME BRMr7 - Collect Information on Oracle Communication BRM 7.0, 7.2, 7.3, or 7.4 =head1 DESCRIPTION This module collects information on BRM or Pipeline Manager-based systems. =cut # Initialisation var $BRM_VERSION = $arg[0] var $BRM_TAIL = getSetting('BRM_TAIL',5000) var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' echo tput('bold'),'Processing Oracle Communication BRM ',$BRM_VERSION,\ ' module ...',tput('off') # --- Data collection macros -------------------------------------------------- # Collect information for BRM Base macro run_portal {var () = @arg import $TOP # Check the presence of required environment variables var $hom = getEnv('PIN_HOME') var $log = getEnv('PIN_LOG',getEnv('PIN_LOG_DIR')) if !and($hom,$log) return 'PIN_HOME and PIN_LOG/PIN_LOG_DIR must be set' # Process all components debug ' Inside BRMr7 module, processing all components (can take time)' pretoc '2:Components' prefix {write '---++ Components' write '' } var %inv = ('dd',1,'config',1,'data',1,'msgs',1) loop $nam (find_elements($hom,'sys',\%inv)) {debug ' ',$nam,' ...' pretoc "3:Component '",$nam,"'" write "Component '",$nam,"'" if match($nam,'^(cm$|dm_oracle)') call send_sigusr1($log,$nam) elsif compare('eq',$nam,'dm_timos') {if process_timos($hom) {write last echo last } next } call process_element($hom,$log,'sys',$nam) if compare('eq',$nam,'dm_ifw_sync') call copy_file('f',catDir($hom,'sys','dm_ifw_sync'),'ifw_sync_queuenames') unpretoc } if hasOutput(true) {write '' write $TOP } unpretoc # Process all applications debug ' Inside BRMr7 module, processing all applications (can take time)' pretoc '2:Applications' prefix {write '---++ Applications' write '' } var %inv = () loop $nam (find_elements($hom,'apps',\%inv)) {debug ' ',$nam,' ...' pretoc "3:Application '",$nam,"'" write "Application '",$nam,"'" call process_element($hom,$log,'apps',$nam) unpretoc } if hasOutput(true) {write '' write $TOP } unpretoc # Indicate a successful completion return '' } # Collect the pipeline information macro run_program {var ($reg,$int) = @arg var $nam = basename($reg,'.reg') var $pgm = "ifw" debug ' Inside BRMr7 module, gathering pipeline information for ',$nam write '---+ Registry ',encode($nam),' from ',encode($int) # Check the presence of required environment variables var $hom = $int if !$hom return 'INT_HOME is not set' # Check if the package can be initialized pretoc "2:Registry '",encode($nam),"'"," from '",encode($int),"'" var $alt = getEnv('PIN_HOME') var @dir = (getEnv('INT_PERL_LIB'),\ catDir($hom,'tools','PerlLib'),\ catDir($hom,'ThirdPartyApps','tools','PerlLib'),\ cond($alt,list(catDir($alt,'tools','PerlLib'),\ catDir($alt,'ThirdPartyApps','tools','PerlLib')),\ list())) if extern('PrRegRd','check_package',@dir) {var $msg = last write 'Cannot access registry:%BR%' return $msg } # Read the registry write '' debug " Inside BRMr7 module, reading registry '",$reg,"'" write "Reading registry '",encode($reg),"'" var $inf = extern('PrRegRd','read_registry',$reg) if !ref($inf) {write 'Cannot read registry:%BR%' return getDataError() } write 'Registry read done' # Copy registries pretoc '3:Registry' debug ' Inside BRMr7 module, copying registries' write write 'Copying registries ...' var $pre = concat('reg_',$nam) call copy_file($pre,$hom,$reg) call copy_file($pre,$hom,info2file($hom,getDataValue($inf,'Info'))) write 'Registry copy done' unpretoc # Copy descriptions pretoc '3:Descriptions' debug ' Inside BRMr7 module, copying descriptions' write write 'Copying descriptions ...' var $pre = concat('dsc_',$nam) call copy_file($pre,$hom,getDataValue($inf,'Alias')) loop $pth (getDataKeys($inf,'FormatDescs')) call copy_file($pre,$hom,$pth) write 'Description files copy done' unpretoc # Collect log files pretoc '3:Log Files' debug ' Inside BRMr7 module, collecting log files' write write 'Collecting log file newest entries ...' write '(only 10 newest Stream-Logs/Format)' var $pre = concat('log_',$nam) loop $pth (find_logs($hom,$inf)) call tail_file($pre,$hom,$pth) write 'Log File copy done ...' unpretoc # Copy trace files pretoc '3:Trace Files' debug ' Inside BRMr7 module, collecting trace files' write write 'Copying trace files ...' var $pre = concat('trc_',$nam) loop $pth (grepDir($hom,'trace','np')) call copy_file($pre,$hom,$pth) write 'Trace file copy done' unpretoc # Get Pipeline Manager information if testFile('x',catFile($hom,'bin',$pgm)) {debug ' Inside BRMr7 module, collecting pipeline information' write write 'Collecting pipeline information ...' var $cmd = concat(lastCommand(),' -v') suspend log report concat('ifw_',$nam,'_',$int) write '---+ Pipeline Information' write '---++ Using: ',encode($cmd) var $rpt = getFile() var $tmp = getTemp('ifw') call command(concat($cmd,' 2>',quote($tmp,'x'))) call writeFile($tmp) call unlinkTemp('ifw') suspend rpt resume log write " '",encode($cmd),"' -> ",cond(expr('>>',status(),8),'failed',$rpt) var $cmd = concat($cmd,' -r ',quote($reg,'x')) suspend log resume rpt write '---++ Using: ',encode($cmd) var $tmp = getTemp('ifw') call command(concat($cmd,' 2>',quote($tmp,'x'))) call writeFile($tmp) call unlinkTemp('ifw') toc '3:[[',$rpt,'][rda_report][Pipeline Information]]' resume log write " '",encode($cmd),"' -> ",cond(expr('>>',status(),8),'failed',$rpt) } write 'Collect done' write '' unpretoc return '' } # --- Internal collection macros ---------------------------------------------- # Collect log and pinlog files macro collect_logs {var ($log,$sub,$nam,$dir,$fil,$pat) = @arg # Initialisation var $cnt = 0 var $pat = concat($pat,'(.*)$') # Read start script if createBuffer('PIN','R',catFile($dir,$fil)) {while getLine('PIN') {var $lin = chomp(last) next match($lin,'^#') if match($lin,$pat) incr $cnt,tail_file('t',$dir,replaceEnv(trim(substr(last,1)))) } call deleteBuffer('PIN') } else write 'Cannot open ',encode($fil) # Copy log file if exists if compare('eq',$nam,'batch_controller') var $log_file = 'BatchController.log' else var $log_file = concat($nam,'.log') if or(testFile('e',catFile($log,$nam,$log_file)),\ testFile('e',catFile($dir,$log_file))) incr $cnt,tail_file('t',$dir,lastFile()) # Return the number of files found return $cnt } # Find all the components for collecting logs macro find_elements {var ($hom,$sub,\%inv) = @arg var ($cnt,@tbl) = (0) var $dir = catDir($hom,$sub) loop $nam (grepDir($dir,'^\.\.?$','nv')) {next !testDir('d',catDir($dir,$nam)) next exists($inv{$nam}) var @tbl = (@tbl,$nam) incr $cnt } if !$cnt debug 'There are no elements available in ',$dir return @tbl } # Find all log file names and verify their existence macro find_logs {var ($dir,$inf) = @arg var %tbl = () # Search for logs if $inf {# Examine process log var $pth = info2file($dir,getDataValue($inf,'Process')) if testFile('fr',$pth) var $tbl{$pth} = 1 # Examine format logs loop $itm (getDataValue($inf,'FormatLogs')) {var $pth = info2file($dir,$itm) if testFile('fr',$pth) var $tbl{$pth} = 1 } # Examine stream logs loop $itm (getDataValue($inf,'StreamLogs')) {var $cnt = 10 var $pth = getDataValue($itm,'Path') if !isAbsolute($pth) var $pth = catFile($dir,$pth) loop $pth (grepDir($pth,\ concat(getDataValue($itm,'Prefix'),'.*',\ getDataValue($itm,'Suffix')),\ 'pt')) {var $tbl{$pth} = 1 decr $cnt break !$cnt } } } # Report all logs found loop $nam (keys(%tbl)) write ' ',encode($nam) return keys(%tbl) } # Derive the file path from the data structure macro info2file {var ($dir,$inf) = @arg if defined($inf) {var $pth = catFile(getDataValue($inf,'Path'),\ concat(getDataValue($inf,'Prefix'),\ getDataValue($inf,'Name'),\ getDataValue($inf,'Suffix'))) return cond(isAbsolute($pth),$pth,catFile($dir,$pth)) } return undef } # Collect logs for each component macro process_element {var ($hom,$log,$sub,$nam) = @arg # Initialisation var $dir = catDir($hom,$sub,$nam) # Copy pinlog and log files when pin.conf exists var $fil = 'pin.conf' if and(testFile('e',catFile($dir,$fil)),\ collect_logs($log,$sub,$nam,$dir,$fil,'logfile')) call copy_file('f',$dir,$fil) # Check for Infranet.properties only for applications var $fil = 'Infranet.properties' if and(testFile('e',catFile($dir,$fil)),\ collect_logs($log,$sub,$nam,$dir,$fil,'infranet.log.file')) call copy_file('f',$dir,$fil) # Copy default.pinlog when exists var $fil = 'default.pinlog' if testFile('e',catFile($dir,$fil)) {call tail_file('t',$dir,$fil) if compare('eq',$nam,'test') call copy_file('f',$dir,'pin.conf') } # Copy core when exists call copy_data('f',$dir,'core') } # Process timos component macro process_timos {var ($hom) = @arg # Copy the registry file var $dir = catDir($hom,'sys','dm_timos') call copy_file('timos_',$dir,'timos.reg') # Check if the package can be initialized var @dir = (getEnv('INT_PERL_LIB')) loop $env ('INT_HOME','PIN_HOME') {if getEnv($env) var @dir = (@dir,catDir(last,'tools','PerlLib'),\ catDir(last,'ThirdPartyApps','tools','PerlLib')) } if extern('PrRegRd','check_package',@dir) {var $msg = last write 'Cannot access registry:%BR%' return $msg } # Read the registry var $reg = catFile($dir,'timos.reg') write " Reading registry '",encode($reg),"'" var $inf = extern('PrRegRd','read_timos',$reg) if !ref($inf) {write 'Cannot read registry:%BR%' return getDataError() } write ' Registry read done' # Copy registry files call copy_file('timos_',$dir,getDataValue($inf,'PinLog')) call copy_file('timos_',$dir,info2file($dir,getDataValue($inf,'LogServer'))) call copy_file('timos_',$dir,'pin.conf') return '' } # Send SIGUSR1 signal to dm_oracle and cm processes macro send_sigusr1 {var ($log,$nam) = @arg # Get process id from PID_FILE var $fil = catFile($log,$nam,concat($nam,'.pid')) var ($pid) = grepFile($fil,'\d+','f') if !$pid {write "Cannot open ",encode($fil) return 1 } # Check the process existence before sending SIGUSR1 if !kill(0,$pid) {write ' ',$nam,' process (',$pid,') is not in running state' return 1 } if !kill('USR1',$pid) {write ' Successfully sent the signal SIGUSR1 to ',$pid return 1 } write ' Failed to send signal SIGUSR1 to ',$pid return 0 } # --- File copy macros -------------------------------------------------------- # Copy a data file macro copy_data {var ($pre,$dir,$fil) = @arg if length($fil) {if !isAbsolute($fil) var $fil = catFile($dir,$fil) if testFile('e',$fil) {suspend log data concat($pre,$fil) var $nam = basename($fil) var $ret = writeData($fil) var $rpt = getFile() if isCreated(true) toc '4:[[',$rpt,'][rda_report][',$nam,']]' resume log write ' ',encode($fil),' -> ',cond($ret,$rpt,'failed') } } } # Copy a file macro copy_file {var ($pre,$dir,$fil) = @arg if length($fil) {if !isAbsolute($fil) var $fil = catFile($dir,$fil) if testFile('e',$fil) {suspend log report concat($pre,$fil) prefix {write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) } var $nam = basename($fil) var $ret = writeFile($fil) var $rpt = getFile() if isCreated(true) toc '4:[[',$rpt,'][rda_report][',$nam,']]' resume log write ' ',encode($fil),' -> ',cond($ret,$rpt,'failed') } } } # Tail a file macro tail_file {var ($pre,$dir,$fil) = @arg import $BRM_TAIL keep $BRM_TAIL var $ret = 0 if length($fil) {if !isAbsolute($fil) var $fil = catFile($dir,$fil) if testFile('e',$fil) {suspend log report concat($pre,$fil) prefix {write '---+ Last ',$BRM_TAIL,' Lines of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) } var $nam = basename($fil) var $ret = writeTail($fil,$BRM_TAIL) var $rpt = getFile() if isCreated(true) {var $ret = 1 toc '4:[[',$rpt,'][rda_report][',$nam,']]' } resume log write ' ',encode($fil),' -> ',cond($ret,$rpt,'failed') } } return $ret } =head1 BRM BASE The following reports can be generated and are regrouped under C: =head2 pin_log - Collection Log Provides the collection details. =head2 Pin and log files Collects all log and pinlog files of all components and all applications. =cut if getSetting('BRM_PORTAL') {debug ' Inside BRMr7 module, gathering BRM Base information' toc '1:BRM Base (',$BRM_VERSION,')' report pin_log write '---+!! BRM Base Information' write $TOC toc '2:[[',getFile(),'][rda_report][Collection Log]]' if run_portal() {write last echo last } pretoc '2:Extra Files' prefix {write '---++ Extra Files' write '' } call copy_file('x',getEnv('HOME'),'vpd.properties') if getEnv('PIN_HOME') call copy_file('x',catDir(last,'bin'),'pinrev.dat') if getEnv('PIN_LOG',getEnv('PIN_LOG_DIR')) call copy_file('x',last,'portal_patchlog') if hasOutput(true) {write '' write $TOP } unpretoc } =head1 PIPELINE BASED SYSTEM The following reports can be generated and are regrouped under C: =head2 ifw_log - Collection Log Provides the collection details. =head2 Registry, description, log and trace files. Reads the specified registry files and collects information such as description, log, and trace files for each of the registry files. It captures the pipeline information also. =cut if getSetting('BRM_REGISTRY') {var ($all,%dir) = (last) debug ' Inside BRMr7 module, gathering Pipeline Manager information' if isTocCreated(true) toc '%SPLIT%' toc '1:Pipeline Manager(',$BRM_VERSION,')' report ifw_log write '---+!! Pipeline Manager Information' write $TOC toc '2:[[',getFile(),'][rda_report][Collection Log]]' if getSetting('BRM_ONE_HOME') {var $dir = getSetting('BRM_INT_HOME',getEnv('INT_HOME')) var $dir{$dir} = 1 loop $reg (split('\|',$all)) {if run_program($reg,$dir) {write last echo last } } } elsif getSetting('BRM_REG_SETS') {loop $set (split('\|',last)) {var $dir = getSetting(concat('BRM_INT_',$set)) var $dir{$dir} = 1 if run_program(getSetting(concat('BRM_REG_',$set)),$dir) {write last echo last } } } pretoc '2:Extra Files' prefix {write '---++ Extra Files' write '' } call copy_file('x',getEnv('HOME'),'vpd.properties') loop $dir (keys(%dir)) call copy_file('x',catDir($dir,'bin'),'piperev.dat') if hasOutput(true) {write '' write $TOP } unpretoc } =head1 SEE ALSO L =begin credits =over 10 =item RDA 4.7: Nameer Jalel, Steve Schow. =item RDA 4.8: Nameer Jalel. =item RDA 4.9: Nameer Jalel. =item RDA 4.15: Nameer Jalel, Chetan Prabhakar. =back =end credits =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