# DCgrdn.ctl:450:Collects Oracle Guardian Information # $Id: DCgrdn.ctl,v 1.4 2013/10/30 07:18:32 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/DCgrdn.ctl,v 1.4 2013/10/30 07:18:32 RDA Exp $ # # Change History # 20130421 MSC Improve the validation. =head1 NAME OFM:DCgrdn - Collects Oracle Guardian Information =head1 DESCRIPTION This module collects Oracle Guardian-related diagnostic information for a specified domain. It first tries to activate the domain before performing a C command. The following reports can be generated and are regrouped under C: =cut echo tput('bold'),'Processing OFM.GRDN module ...',tput('off') # Initialization var $BUNDLE = ${N_BUNDLE} var $DOMAIN = ${T_DOMAIN} var $INSTALL = ${D_LOCATION:''} var $TIMEOUT = ${N_TIMEOUT} var $HOST = ${T_HOST} var $PORT = ${N_PORT} var $USER = uc(${T_USER}) var $WORKSPACE = ${D_WORKSPACE:''} var $MOD = cond(isUnix(),'fx','fr') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:Oracle Guardian' # Check Guardian availability if ?testFile($MOD,catFile($INSTALL,${AS.EXE:'guardian'})) var $pgm = lastTestCommand() else {echo 'Oracle Guardian executable not available' return } # Validate settings if !match($USER,'^[A-Z0-9][\w\$\#]{0,29}$') {echo 'Invalid Oracle WebLogic domain user name' return } if !match($DOMAIN,'^[\w\.\-]+$') {echo 'Invalid domain identifier' return } if !match($HOST,'^[\w\-\.]+$') {echo 'Invalid host' return } if !match($PORT,'^\d+$') {echo 'Invalid port' return } if !match($BUNDLE,'^\d+$') {echo 'Invalid bundle' return } if and(match($TIMEOUT,'^\d+$'),expr('>',$TIMEOUT,0)) var @opt = ('-o',$TIMEOUT) else var @opt = () var $PWD = ['pseudo','host','GUARDIAN_USER',\ "Enter the password for WebLogic user ${VAR.USER}:",''] # Try to activate the domain var $URL = concat('http://',$HOST,':',$PORT) debug ' Inside GRDN module, activating the domain' call loadCommand({\ cmd => [$pgm,'-noSplash','-application',\ 'com.bea.support.guardian.ui.headless.Headless','-gactivateDomain',\ '-t',quote($URL),'-u',quote($USER),'-p','%s',@opt,'-data',\ quote($WORKSPACE),'2>&1'],\ pwd => $PWD},false,10) =head2 results - Evaluation Results Collects evaluation results regrouping the inventory information and the detected signatures. =head2 errors - Evaluation Errors Reports evaluation errors. =cut var $DOMAIN = concat($DOMAIN,'_',$HOST,'_',$PORT) # Evaluate the domain in headless mode debug ' Inside GRDN module, running Guardian evaluation (can take time)' call loadCommand({\ cmd => [$pgm,'-noSplash','-application',\ 'com.bea.support.guardian.ui.headless.Headless',\ '-gevaluateDomainBundle','-d',quote($DOMAIN),'-b',quote($BUNDLE),\ '-u',quote($USER),'-p','%s','-data',quote($WORKSPACE),'2>&1'],\ pwd => $PWD},false,10) if grepLastFile('\\sDomain\sevaluated\ssuccessfully','f') {# Display the results when the evaluation is successful debug ' Inside GRDN module, generating evaluation report' report results write "---+!! Evaluation Results" write $TOC toc '2:[[',getFile(),'][rda_report][Evaluation Results]]' # Load inventory information write "---+ Inventory Information" var ($fil) = grepLastFile("\\sSaving\s(.*\.inv)","f") var $fil = replace($fil,"^.*?Saving\s") var $inv = xmlLoadFile(catFile($fil)) write '|*Time Stamp*|',xmlValue(xmlFind($inv,'inv:inventory'),'timestamp'),' |' write '|*Domain*|',xmlValue(xmlFind($inv,'inv:inventory'),'targetName'),' |' var $cnt = xmlFind($inv,'inv:inventory/web:weblogicServer') write '|*Active Servers*|',nvl($cnt,0),' |' write $TOP # Treat all servers write "---+ Server Information" loop $itm (xmlFind($inv,'inv:inventory/web:weblogicServer')) {# Display the server information write "---++ ",xmlValue($itm,'name')," Information" write "---+++!! Server Details" write '|*Version*|', xmlValue($itm,'major'),'.',\ xmlValue($itm,'minor'),'.',\ xmlValue($itm,'servicepack'),'.',\ xmlValue($itm,'rollingpatch'),' |' write '|*Oracle WebLogic Version*|',\ xmlData(xmlFind($itm,'web:weblogicVersion')),' |' write '|*Admin Server*|',xmlValue($itm,'adminServer'),' |' write '|*Production Mode*|',xmlValue($itm,'productionMode'),' |' write '|*Agent Status*|',xmlValue($itm,'agentState'),' |' write $TOP # Display the Java information write "---+++!! Java Details" var $java = xmlFind($itm,'web:java') write '|*Java Vendor*|',\ xmlData(xmlFind($itm,'web:java/web:vendor')),' |' write '|*Java Version*|',\ xmlData(xmlFind($itm,'web:java/web:version')),' |' write '|*Java Virtual Machine Vendor*|',\ xmlData(xmlFind($itm,'web:java/web:vm/web:vendor')),' |' write '|*Java Virtual Machine Version*|',\ xmlData(xmlFind($itm,'web:java/web:vm/web:version')),' |' write '|*Java Virtual Machine Name*|',\ xmlData(xmlFind($itm,'web:java/web:vm/web:name')),' |' write '|*Free Memory*|',xmlData(xmlFind($itm,\ 'web:java/web:memory/web:formattedFree')),' |' write '|*Total Memory*|',\ xmlData(xmlFind($itm,'web:java/web:memory/web:formattedTotal')),' |' write '|*Maximum Memory*|',\ xmlData(xmlFind($itm,'web:java/web:memory/web:formattedMax')),' |' write $TOP # Display the operating system details write "---+++!! Operating System Details" write '|*Name*|',xmlData(xmlFind($itm,'web:os/web:name')),' |' write '|*Version*|',xmlData(xmlFind($itm,'web:os/web:version')),' |' write '|*Architecture*|',xmlData(xmlFind($itm,'web:os/web:arch')),' |' write $TOP } # Display the evaluation details write "---+ Evaluation Details" var ($fil) = grepLastFile("\\sSaving\s(.*\.eval)","f") var $fil = replace($fil,"^.*?Saving\s") var $xml = xmlLoadFile(catFile($fil)) write '|*Duration*|',\ xmlData(xmlFind($xml,'eval:evaluation/eval:durationMillis')),' |' write '|*Time Stamp*|',\ xmlData(xmlFind($xml,'eval:evaluation/eval:timestamp')),' |' write '|*Domain*|',\ xmlValue(xmlFind($xml,'eval:evaluation/eval:domain'),'name'),' |' write '|*Bundle*|',\ xmlValue(xmlFind($xml,'eval:evaluation/eval:bundle'),'name'),' |' var $nbd = xmlFind($xml,'eval:evaluation/eval:detectedSignature') var $nbu = xmlFind($xml,'eval:evaluation/eval:undetectedSignature') write '|*Number of Targeted Signatures*|',expr("+",$nbd,$nbu),' |' write '|*Number of Detected Signatures*|',$nbd,' |' write $TOP # Analyze detected signature loop $itm (xmlFind($xml,'eval:evaluation/eval:detectedSignature')) {var $sig = xmlValue($itm,'id') var $tb_itm{$sig} = $itm var $tb_sev{$sig} = xmlData(xmlFind($itm,'sig:severity')) } # Display the summary of detected signatures prefix {write "---+ Summary List of Detected Signatures" write '|*Severity*|*Name*|*Impact*|*Product*|*Topic*|*Subtopic*|*Identifier*|' } loop $sig (keys(%tb_sev,'SA')) {var $itm = $tb_itm{$sig} write '|',$tb_sev{$sig},' |'\ ,xmlData(xmlFind($itm,'sig:name')),' |'\ ,xmlData(xmlFind($itm,'sig:impact')),' |'\ ,xmlData(xmlFind($itm,'sig:product')),' |'\ ,xmlData(xmlFind($itm,'sig:topic')),' |'\ ,xmlData(xmlFind($itm,'sig:subtopic')),' |[[#Sig'\ ,$sig,'][',$sig,']]|' } # Display the details list of detected signatures with description and remedy if hasOutput(true) {write $TOP macro fmt_text {var $str = join('%BR%',@arg) var $str = replace($str,'\<\/?p\>','
',true) var $str = replace($str,'(\)+','%BR%',true) var $str = replace($str,'\','%LIST%',true) var $str = replace($str,'\<\/li\>','%ENDLIST%',true) var $str = replace($str,'%ENDLIST%%BR%%LIST%','%NEXT%',true) var $str = replace($str,'\|','|',true) var $str = replace($str,'\012','%BR%',true) return $str } write "---+ Detailed List of Detected Signatures" loop $sig (keys(%tb_itm)) {var $itm = $tb_itm{$sig} write '#Sig',$sig,' ---## Signature ',$sig,':' write '|*Name*|',xmlData(xmlFind($itm,'sig:name')),' |' write '|*Severity*|',$tb_sev{$sig},' |' write '|*Product*|',xmlData(xmlFind($itm,'sig:product')),' |' write '|*Impact*|',xmlData(xmlFind($itm,'sig:impact')),' |' write '|*Topic*|',xmlData(xmlFind($itm,'sig:topic')),' |' write '|*Subtopic*|',xmlData(xmlFind($itm,'sig:subtopic')),' |' write '|*Description*|',\ fmt_text(xmlData(xmlFind($itm,'sig:description'))),' |' write '|*Remedy*|',\ fmt_text(xmlData(xmlFind($itm,'sig:remedy/sig:head')),\ xmlData(xmlFind($itm,'eval:remedyDetails')),\ xmlData(xmlFind($itm,'sig:remedy/sig:foot'))),' |' } write $TOP } } else {# If the evaluation fails, display the error messages in the ErrorReport report errors prefix {write "---+ Evaluation Errors" write "" } loop $lin (grepLastFile("ERROR")) write $lin if isCreated(true) {write "" toc '2:[[',getFile(),'][rda_report][Evaluation Errors]]' } } unpretoc =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