# WASlib.ctl: Defines Common Macros for Web Application Server # $Id: WASlib.ctl,v 1.13 2015/10/28 11:12:18 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/WASlib.ctl,v 1.13 2015/10/28 11:12:18 RDA Exp $ # # Change History # 20151028 MSC Use native paths in sub titles. =head1 NAME OFM:WASlib - Defines Common Macros for Web Application Server =head1 DESCRIPTION This persistent submodule regroups macros that are common to several web application server related-modules. The following macros are available: =cut # Make the module persistent and share macros keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('get_app_conf','get_app_log','get_conf',\ 'sort_results','write_latest_incidents') =head2 S This macro collects the application configuration files related to web application servers. =cut macro get_app_conf {var (\@tbl,$dir,$nam,@sub) = @arg if compare('eq',$nam,'ldap') call push(@tbl,grepDir(catDir($dir,@sub,$nam),'\.ldif$','ip')) elsif compare('eq',$nam,'nodemanager') call push(@tbl,grepDir(catDir($dir,@sub,$nam),\ '\.(lck|pid|properties|state|url)$','ip')) elsif compare('eq',$nam,'portal') {call push(@tbl,grepDir(\ catDir($dir,@sub,$nam,$nam,'configuration'),'\.conf$','ip')) } elsif compare('eq',$nam,'OIF') {loop $sub (grepDir(catDir($dir,@sub,$nam),'^\d+(\.\d+){4}$','np')) call push(@tbl,grepDir(catDir($sub,'OIF','web.war'),'\.jsp$','ip')) } elsif compare('eq',$nam,'formsapp') {loop $sub (grepDir(catDir($dir,@sub,$nam),'^\d+(\.\d+){2}$','np')) call push(@tbl,grepDir(catDir($sub,'formsapp','config'),'^\.+$','pv')) } elsif compare('eq',$nam,'reports') {call push(@tbl,grepDir(\ catDir($dir,@sub,$nam,$nam,'configuration'),'^\.+$','pv')) } } =head2 S This macro collects the application log files related to web application servers. =cut macro get_app_log {var (\@tbl,$dir,$nam,$pat,$opt) = @arg var $pat = nvl($pat,'^[^\.]') var $opt = nvl($opt,'dir') if compare('eq',$nam,'formsapp') call push(@tbl,grepDir($dir,$pat,$opt)) elsif compare('eq',$nam,'reports') call push(@tbl,grepDir(catDir($dir,$nam),$pat,$opt)) elsif compare('eq',$nam,'sdp') call push(@tbl,grepDir(catDir($dir,$nam),$pat,$opt)) elsif compare('eq',$nam,'wlcs') call push(@tbl,grepDir(catDir($dir,$nam),$pat,$opt)) elsif compare('eq',$nam,'wsp') call push(@tbl,grepDir($dir,$pat,$opt)) } =head2 S This macro collects the configuration files related to web application servers. =cut macro get_conf {var (\@tbl,$dir,$pat,$opt) = @arg var $pat = nvl($pat,'^\.+$') var $opt = nvl($opt,'drv') call push(@tbl,grepDir($dir,$pat,$opt)) } =head2 S This macro uses the unsorted file list to generate links in the RDA menu structure for each directory and the files located in that directory. =cut macro sort_results {var ($lvl,$lgt,$pre,$abr,@fil) = @arg import $TOP,%DUP keep $TOP,%DUP # Filter the file list loop $fil (@fil) {next !?testFile('frT',$fil) next match($fil,'\.(bmp|exe|gif|jar|jpe?g|wav|wbmp)$',true) var $fil{join("\001",dirname($fil),basename($fil))} = $fil } # Generate the reports and related index links var $lst = '' var $det = $lvl incr $det loop $fil (keys(%fil)) {var $fil = $fil{$fil} # Create the report associated with the file if missing($DUP{$fil}) {# Check for a new section var $grp = dirname($fil) if compare('ne',$grp,$lst) {debug ' Inside sort_results, getting files in ',$grp var $lst = $grp toc $lvl,':',encode(replace($grp,verbatim($pre),$abr)),' ' } var $nam = basename($fil) debug ' - ',$nam output F,concat('log_',$nam) if match($nam,'^USData.xml$',true) {write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode($fil) call statFile('b',$fil) write '**File was not collected, because of the file size.**%BR%' } elsif match($fil,'(logs?[\/\\]|log$)',true) {if exists($LOG{$fil}) var $cnt = $LOG{$fil} else var $cnt = $lgt if $cnt write '---+ Last ',$cnt,' Lines of ',encode($nam),' File' else write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode(catNative($fil)) call statFile('b',$fil) if $cnt call writeTail($fil,$cnt) else call writeFile($fil) write $TOP } else {write '---+ Display of ',encode($nam),' File' write '---## Information Taken from ',encode(catNative($fil)) call statFile('b',$fil) call writeFile($fil) write $TOP } var $rpt = getFile() if $abr var $DUP{$fil} = $rpt if isCreated() toc $det,':[[',$rpt,'][rda_report][',encode($nam),']]' } } } =head2 S This macro gathers files generated by the latest incidents and writes to the report. =cut macro write_latest_incidents {var ($bas,$hom,$rpt,$txt,$lvl,$pbm) = @arg import $INCIDENT_FILES,$ONLY_README,$TOC,$TOP keep $INCIDENT_FILES,$ONLY_README,$TOC,$TOP if $cnt = nvl($INCIDENT_FILES,5) {var $dir = catDir($bas,$hom,'incident') var %tbl = () loop $pth (findDir($dir,'^incdir_\d+$','p')) var $tbl{first(match($pth,'incdir_(\d+)$'))} = $pth # Gather the incident files output F,concat($rpt,'_incident_files') title '---+!! Files from Latest Incidents' title ' * Links point to files that have been collected in their original \ format. Opening them directly in your browser can present \ security risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate viewer.' title ' * Collection of files is including files generated by incidents. \ It may collect other files present in incident directory.' title $TOC loop $num (keys(%tbl,'ID')) {prefix {write '---+ Contents of Incident ',$num,\ cond($pbm,concat(' (Problem Key: ',$pbm->{$num},')')) write '|*File Name*| *Size*|*Last Modification*|' } loop $pth (cond($ONLY_README,catFile($tbl{$num},'readme.txt'),\ grepDir($tbl{$num},'^(\.+|da_.+_.+_\d{14}\.zip)$','pv'))) {next !?testDir('f',$pth) output d,concat($rpt,'_',$num,'_',$fil = basename($pth)) if ${CUR.O_LAST}->write_data($pth) write '|[[',${CUR.O_LAST}->get_raw(true),'][_blank][',encode($fil),']]| ',\ getSize($pth),'|',getLastModify($pth,''),' |' end ${CUR.O_LAST} } if hasOutput(true) {write $TOP decr $cnt break !$cnt } } if isCreated(true) toc $lvl,':[[',getFile(),'][rda_report][',$txt,']]' } } =begin credits =over 10 =item RDA 4.25: Greg Cook, Andrew Salt. =item RDA 4.26: Maria Salzberger. =back =end credits =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