# DCoaam.ctl:363:Collects Oracle Adaptive Access Manager Information # $Id: DCoaam.ctl,v 1.8 2015/08/21 15:30:22 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/DCoaam.ctl,v 1.8 2015/08/21 15:30:22 RDA Exp $ # # Change History # 20150821 MSC Improve time consistency. =head1 NAME OFM:DCoaam - Collects Oracle Adaptive Access Manager Information =head1 DESCRIPTION This module collects information about Oracle Adaptive Access Manager. The database information is extracted from an Oracle database only. The following reports can be generated and are regrouped under C: =cut echo tput('bold'),'Processing OFM.OAAM module ...',tput('off') # Initialization var $AGE = ${R_AGE/T:1} var $APACHE_TOP = ${D_APACHE_TOP:''} var $OAAM_HOME = ${D_HOME:''} var $OAAM_RDBMS = ${B_RDBMS} var $MOD = cond(isWindows(),'f',isCygwin(),'f','fr') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:Oracle Adaptive Access Manager' # Load the common macros run DB:DBinfo() run RDA:library() # --- RDBMS collections -------------------------------------------------- if $OAAM_RDBMS {call setSqlTarget(${I_DB}) =head2 dbver - Database Version Information Collects the database version information. =cut if !testSql() {debug ' Inside OAAM module, gathering version information' report dbver write '---+!! Database Version Information' toc '2:[[',getFile(),'][rda_report][Database Version Information]]' set $sql {SELECT '|' || banner || '|' " FROM v$version; } prefix {write '---+ Oracle Database Versions from V$Version' write '|*Banner*|' } call writeSql($sql) =head2 patches - Patches Information Collects patches information. =cut debug ' Inside OAAM modules, gathering patches information' report patches var ($hdr,$col) = getSqlColumns('RDA','','vcrypt_db_patches') call clearSqlColumns('RDA') prefix {write '---+!! Patches Information' write $hdr } set $sql {SELECT :1 " FROM vcrypt_db_patches " ORDER BY patch_id DESC; } call writeSql(bindSql($sql,$col)) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Patches Information]]' =head2 avg_rt - Average Run-Time Information Collects rule cost query average per run-time. =cut debug ' Inside OAAM modules, gathering average run-time information' report avg_rt prefix write '---+!! Rule Cost Query Average Per Run-Time' write $TOC var @TTL = ('',\ '---+ Last 24 hours',\ '---+ Last 7 days',\ '---+ Last 15 days',\ '---+ Last 30 days') var @HDR = ('',\ '| *Policyset ID*| *Run-Time Type*| *Average Time*|',\ '| *Policyset ID*| *Run-Time Type*| *Average Time*|',\ '| *Policyset ID*| *Run-Time Type*| *Average Time*|',\ '| *Policyset ID*| *Run-Time Type*| *Average Time*|') set $sql {SELECT '| ' || " policyset_id || '| ' || " runtime_type || '| ' || " AVG(total_time) || '|' " FROM vr_policyset_logs " WHERE total_time > 100 " AND create_time > SYSDATE - 1 " GROUP BY policyset_id, runtime_type " ORDER BY AVG(total_time) DESC; "PROMPT ___Macro_separator(2)___ "SELECT '| ' || " policyset_id || '| ' || " runtime_type || '| ' || " AVG(total_time) || '|' " FROM vr_policyset_logs " WHERE total_time > 100 " AND create_time > SYSDATE - 7 " GROUP BY policyset_id, runtime_type " ORDER BY AVG(total_time) DESC; "PROMPT ___Macro_separator(3)___ "SELECT '| ' || " policyset_id || '| ' || " runtime_type || '| ' || " AVG(total_time) || '|' " FROM vr_policyset_logs " WHERE total_time > 100 " AND create_time > SYSDATE - 15 " GROUP BY policyset_id, runtime_type " ORDER BY AVG(total_time) DESC; "PROMPT ___Macro_separator(4)___ "SELECT '| ' || " policyset_id || '| ' || " runtime_type || '| ' || " AVG(total_time) || '|' " FROM vr_policyset_logs " WHERE total_time > 100 " AND create_time > SYSDATE - 30 " GROUP BY policyset_id, runtime_type " ORDER BY AVG(total_time) DESC; } call separator(1) call writeSql($sql) call separator(0,'Average Run-Time Information') =head2 runtime - Models and Rules Run-Time Statistics Collects models and rules run-time statistics. =cut debug ' Inside OAAM modules, gathering run-time information' report runtime prefix {write '---+!! Models and Rules Run-Time Statistics' write '|*Model* | *Rule Instance Name*|*Average Time*| *Maximum Time*| \ *Execution Count*|' } set $sql {SELECT '|' || " p.profile_name || ' |' || " rm.map_name || ' | ' || " AVG(rl.total_time) || '| ' || " MAX(rl.total_time) || '| ' || " COUNT(1) || '|' " FROM vr_rule_logs rl, " vr_model_logs ml, " vr_policy_logs pl, " vr_policyset_logs psl, " vcrypt_profile_rule_map rm, " vcrypt_profile p, " vcrypt_rule r " WHERE rl.rule_map_id = rm.profile_rule_map_id " AND pl.policyset_log_id = psl.policyset_log_id " AND ml.policy_log_id = pl.policy_log_id " AND rl.model_log_id = ml.model_log_id " AND r.rule_id = rm.rule_id " AND p.profile_id = rm.profile_id " AND rl.total_time > 0 " GROUP BY p.profile_name, rm.map_name, rm.notes, r.rule_name, r.notes " ORDER BY AVG(rl.total_time) DESC; } call writeSql($sql) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Models and Rules Run-Time Statistics]]' } } =head2 models - Module Models Collects the module models. =cut if ?nvl(testFile($MOD,catFile(catDir($OAAM_HOME,'oaam','cli'),\ ${AS.CMD:'runImportExport'})),\ testFile($MOD,catFile(catDir($OAAM_HOME,'oaam_cli','oaam_cli'),\ 'scripts',${AS.CMD:'runImportExport'}))) {var $cmd = lastCommand() var $old = setLocalEnv('BHCLI_HOME',lastDir()) var $box = cleanBox() debug ' Inside OAAM modules, gathering module models' report models var $exe = concat($cmd,' --action export --module models 2>&1') if or(isWindows(),isCygwin()) {var $job = createTemp('MOD','.bat',true) call writeTemp('MOD','@echo off') call writeTemp('MOD','cd /d "',getNativePath($box),'"') call writeTemp('MOD',$exe) call closeTemp('MOD') call command($job) call unlinkTemp('MOD') } elsif isUnix() {var $job = createTemp('MOD','.sh',true) call writeTemp('MOD','cd "',$box,'"') call writeTemp('MOD',$exe) call closeTemp('MOD') call command($job) call unlinkTemp('MOD') } prefix {write '---+!! Module Models' write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $fil (grepDir(catDir($box,'exportData','models'),'.*','pn')) {if ?testFile($MOD,$fil) {var $bas = basename($fil) var $lnk = encode($bas) var $siz = getSize($fil) if $siz {output b,$bas if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),'][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Module Models]]' =head2 properties - Module Properties Collects the module properties. =cut debug ' Inside OAAM modules, gathering module properties' report properties var $exe = concat($cmd,' --action export --module properties 2>&1') if or(isWindows(),isCygwin()) {var $job = createTemp('PRP','.bat',true) call writeTemp('PRP','@echo off') call writeTemp('PRP','cd /d "',getNativePath($box),'"') call writeTemp('PRP',$exe) call closeTemp('PRP') call command($job) call unlinkTemp('PRP') } elsif isUnix() {var $job = createTemp('PRP','.sh',true) call writeTemp('PRP','cd "',$box,'"') call writeTemp('PRP',$exe) call closeTemp('PRP') call command($job) call unlinkTemp('PRP') } prefix {write '---+!! Module Properties' write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $fil (grepDir(catDir($box,'exportData','properties'),'.*','pn')) {if ?testFile($MOD,$fil) {var $bas = basename($fil) var $lnk = encode($bas) var $siz = getSize($fil) if $siz {output b,$bas if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),'][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Module Properties]]' call setLocalEnv('BHCLI_HOME',$old) call cleanBox() } =head2 UIO Apache Proxy Information Collects the Universal Installation Option (UIO) Apache Proxy-related information. =head3 apache_version - Apache Version Gathers Apache version information. =cut if ?testDir('dr',$APACHE_TOP) {pretoc '2:UIO Apache Proxy Information' # Get the apache version if ?testFile($MOD,catFile($APACHE_TOP,'bin',${AS.EXE:'httpd'})) {debug ' Inside OAAM module, getting apache version information' if or(isWindows(),isCygwin()) var $cmd = concat(lastCommand(),' -version') else var $cmd = concat(lastCommand(),' -v') report apache_version prefix {write '---+ Apache Version Information' write '---## Using: ',encode($cmd) } call writeCommand($cmd) if isCreated(true) toc '3:[[',getFile(),'][rda_report][Apache Version]]' } # Collect config and log files if ?testFile('fr',catFile($APACHE_TOP,'conf','httpd.conf')) {# Read the configuration file macro apache_readConf {var (\%cfg,$fil) = @arg loop $lin (grepFile($fil,\ '^\s*(ServerRoot|LoadModule uio_module|UioProxySettingsFile)\s+','ij')) {var $val = trim(replace($lin,'^\s*\w+\s+'),"[\0x22\0x27]") if match($lin,'^\s*ServerRoot\s+',true) {if and(testDir('dr',$val = catDir($val)),not(sameDir($val,$bas))) var $bas = $val } elsif match($lin,'^\s*LoadModule uio_module\s+',true) {var $val = trim(replace($lin,'^\s*\w+\s+'),"[\0x22\0x27]") if !isAbsolute($val = catFile($val)) var $val = catFile($bas,$val) var $cfg{'mod'} = $val } elsif match($lin,'^\s*UioProxySettingsFile\s+',true) {if !isAbsolute($val = catFile($val)) var $val = catFile($bas,$val) var $cfg{'cfg'} = $val } } } # Get the mod_uio.so file and settings file var (@cfg,@log,%cfg) = () call apache_readConf(\%cfg,$cfg = lastFile()) # Parse the UIO proxy settings file if ?testFile('fr',catFile($cfg{'cfg'})) {var $obj = xmlLoadFile(lastFile(),xmlDisable(xmlParser(),'BCDEPR')) # Get the UIO Apache Proxy related configuration files loop $xml (xmlFind($obj,'UIO_ProxySettings/ConfigFile enabled="^true$"')) {var $fil = xmlValue($xml,'location') if and(length($fil),isAbsolute(catFile($fil))) call push(@cfg,lastFile()) } # Get the log files related to UIO Apache Proxy if xmlFind($obj,'UIO_ProxySettings/Log4jProperties') {var $fil = xmlValue(first(last),'location') if and(length($fil),testFile('fr',catFile($fil))) {var $obj = xmlLoadFile(lastFile(),xmlDisable(xmlParser(),'BCDEPR')) loop $xml (xmlFind($obj,\ 'log4j:configuration/appender/param name="^File$"')) {var $fil = xmlValue($xml,'value') if and(length($fil),isAbsolute(catFile($fil))) call push(@log,lastFile()) } } } } =head3 Configuration Files Collects the UIO Apache Proxy-related configuration files defined in the F file. =head3 mod_uio - mod_uio.so Gathers the F file. =cut debug ' Inside OAAM module, gathering UIO apache proxy-related config files' pretoc '3:Configuration Files' # Collect the mod_uio.so file report mod_uio prefix {write '---+ mod_uio.so File' write ' * Links point to file that have been collected in their \ original format. Opening them directly in your browser \ can present risks. To prevent them, access the file \ outside the browser or use the link to save them and use \ an adequate viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } if ?testFile('r',$fil = $cfg{'mod'}) {var $lnk = encode($fil) var $siz = getSize($fil) if $siz {output b,concat('uio_',basename($fil)) if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),'][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } if isCreated(true) toc '4:[[',getFile(),'][rda_report][mod_uio.so]]' # Collect the configuration files call sort_files(4,0,$cfg,$cfg{'cfg'},@cfg) unpretoc =head3 Log Files Collects the UIO Apache Proxy-related log files defined in the F file. =cut debug ' Inside OAAM module, gathering UIO apache proxy-related log files' pretoc '3:Log Files' call sort_files(4,$TAIL,@log) unpretoc } unpretoc } =head1 FOR EACH SPECIFIED APPLICATION HOME =head2 Property Files Collects F and F files. =head2 Log Files Collects the log files defined in the F file that is contained inside the application home. =head2 Directory Contents Collects the files from the application home directory and from its F subdirectory. =cut loop $key (${CUR.O_MODULE}->grep('^W_SRV\d+$')) {var $srv = ${CUR.O_MODULE}->get_first($key) var $sid = substr($key,5) pretoc "0: * '",$srv,"' Server" debug ' Inside OAAM module, gathering information from ',$srv loop $sub (${CUR.O_MODULE}->grep(concat('^T_SRV',$sid,'_APP\d+$'))) {var $app = ${CUR.O_MODULE}->get_first($sub) var $pth = ${CUR.O_MODULE}->get_first(\ concat(replace($sub,'^T_','D_'),'_PATH')) var $aid = substr($sub,length(concat('T_SRV',$sid,'_APP'))) pretoc '%SPLIT%' pretoc "1++:'",$app,"' Application" pretoc '2: Property Files' debug ' Inside OAAM module, gathering property files for ',$app loop $nam ('oaam_version.properties','bharosa_server.properties') {var $dir = catDir($pth,'WEB-INF','classes') call cat_report($dir,$nam,concat('s_',$sid,'_a_',$aid)) } unpretoc debug ' Inside OAAM module, gathering log files for ',$app var @log = () if ?testFile('fr',catFile($pth,'WEB-INF','classes','log4j.xml')) {var $obj = xmlLoadFile(lastFile(),xmlDisable(xmlParser(),'BCDEPR')) loop $xml (xmlFind($obj,'log4j:configuration/appender/param')) {var $typ = xmlValue($xml,'name') if compare('eq',$typ,'File') {var $log = xmlValue($xml,'value') if isAbsolute($log) call push(@log,catFile($log)) else call push(@log,catFile($pth,$log)) } } } if @log {report concat('a_',$sid,'_',$aid,'_logs') prefix {write '---+!! Log Files' write ' * Limited to last ',$AGE,' days' write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $log (@log) {var $nam = basename($log) var $dir = dirname($log) loop $fil (grepDir($dir,concat('^',$nam,'.*'),'ipt')) {break isOlder($fil,$AGE) var $lnk = encode($fil) var $siz = getSize($fil) if $siz {output d,concat('a_',$sid,'_',$aid,'_',basename($fil)) if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),\ '][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Log Files]]' } pretoc '2: Directory Contents' debug ' Inside OAAM module, gathering directory contents for ',$app var $cnt = 0 loop $dir (undef,catDir('WEB-INF','classes')) {report concat('a_',$sid,'_',$aid,'_',incr($cnt),'_cont') prefix {write '---+!! Directory Contents' write '---## From ',lastDir() write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $fil (grepDir(catDir($pth,nvl($dir,'.')),\ '\.(cmd|csv|js|jsp|keystore|lst|properties|rule|sh|txt|xml|xsl)$','pn')) {if ?testFile($MOD,$fil) {var $lnk = encode($fil) var $siz = getSize($fil) if $siz {output d,concat('a_',$sid,'_',$aid,'_',basename($fil)) if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),\ '][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '3:[[',getFile(),'][rda_report][',nvl($dir,'TOP'),']]' } unpretoc 3 } unpretoc } =head1 FOR THE LOCATION LOADER HOME =head2 Property Files Collects F and F files. =head2 Log Files Collects the log files defined in the F file that is contained inside the Location Loader home. =head2 Directory Contents Collects the files from the Location Loader home directory and from its F subdirectory. =cut if ${B_LOCATION} {debug ' Inside OAAM module, gathering information from location loader' var $LOC = ${D_LOCATION_TOP:''} pretoc '%SPLIT%' pretoc "1+:Location Loader" pretoc '2: Property Files' debug ' Inside OAAM module, gathering location loader property files' var $dir = catDir($LOC,'conf') loop $nam ('oaam_version.properties','bharosa_location.properties') call cat_report($dir,$nam) call cat_report($LOC,'bharosa_location.properties') unpretoc debug ' Inside OAAM module, gathering location loader log files' var @log if ?testFile('fr',catFile($LOC,'conf','log4j.xml')) {var $obj = xmlLoadFile(lastFile(),xmlDisable(xmlParser(),'BCDEPR')) loop $xml (xmlFind($obj,'log4j:configuration/appender/param')) {var $typ = xmlValue($xml,'name') if compare('eq',$typ,'File') {var $log = xmlValue($xml,'value') if isAbsolute($log) call push(@log,catFile($log)) else call push(@log,catFile($LOC,$log)) } } } if @log {report loc_logs prefix {write '---+!! Log Files' write ' * Limited to last ',$AGE,' days' write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $log (@log) {var $nam = basename($log) var $dir = dirname($log) loop $fil (grepDir($dir,concat('^',$nam,'.*'),'ipt')) {break isOlder($fil,$AGE) var $lnk = encode($fil) var $siz = getSize($fil) if $siz {output d,basename($fil) if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),\ '][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Log Files]]' } pretoc '2: Directory Contents' debug ' Inside OAAM module, gathering location loader directory contents' var $cnt = 0 loop $dir ($LOC,catDir($LOC,'conf')) {report concat('cont_',incr($cnt)) prefix {write '---+!! Directory Contents' write ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' write '|*File Name*| *Size*|*Last Modified Date*|' } loop $fil (grepDir($dir,\ '\.(cmd|csv|js|jsp|keystore|lst|properties|rule|sh|txt|xml|xsl)$','pn')) {if ?testFile($MOD,$fil) {var $lnk = encode($fil) var $siz = getSize($fil) if $siz {output d,basename($fil) if ${CUR.O_LAST}->write_data($fil) var $lnk = concat('[[',${CUR.O_LAST}->get_raw(true),\ '][_blank][',$lnk,']]') end ${CUR.O_LAST} } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } } if isCreated(true) toc '3:[[',getFile(),'][rda_report][',replace($dir,$LOC,'LOCATION_HOME'),']]' } unpretoc 3 } =head2 Oracle WebLogic Server Domain Information It includes all reports produced by the L module for the specified Oracle WebLogic Server domain. =cut toc '%PUSH("%SPLIT%")%' toc '%PUSH("1+:Oracle WebLogic Server Overview")%' toc '%INCLUDE("OFM_WREQ_OFM_OAAM_WH_TF.toc")%' toc '%POP2%' toc '%PUSH("%SPLIT%")%' toc '%PUSH("1+:Oracle WebLogic Server Domain")%' toc '%INCLUDE("OFM_WREQ_OFM_OAAM_DOM_TF.toc")%' toc '%POP2%' unpretoc =head1 SEE ALSO L, L, L =begin credits =over 10 =item RDA 4.22: Uday Sambhara. =item RDA 4.29: Prakash Hegde, Uday Sambhara. =item RDA 4.31: Vikas Ojha. =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