# S450GRDN.def: Collects Oracle Guardian Information # $Id: S450GRDN.def,v 2.5 2012/01/03 13:34:46 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/S450GRDN.def,v 2.5 2012/01/03 13:34:46 mschenke Exp $ # # Change History # 20120103 MSC Change the copyright notice. =head1 NAME S450GRDN - 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 Oracle Guardian module ...',tput('off') # Initialization var $BUNDLE = getSetting('GRDN_BUNDLE') var $DOMAIN = getSetting('GRDN_DOMAIN') var $INSTALL = getSetting('GRDN_LOCATION') var $TIMEOUT = getSetting('GRDN_TIMEOUT') var $HOST = getSetting('GRDN_HOST') var $PORT = getSetting('GRDN_PORT') var $USER = uc(getSetting('GRDN_USER')) var $WORKSPACE = getSetting('GRDN_WORKSPACE') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:Oracle Guardian' # Check Guardian availability if testFile('fx',catFile($INSTALL,cond(isWindows(),'guardian.exe',\ isCygwin(), 'guardian.exe',\ 'guardian'))) var $pgm = lastCommand() 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 = () # Get the user password if getSetting('SQL_PASSWORD_GUARDIAN_USER') var ($pwd) = unpack('u',last) else var $pwd = askPassword(concat('Enter the password for WebLogic user ',\ $USER,':')) if !match($pwd,'^[A-Za-z0-9\_\.\-]*') {echo 'Invalid password' return } # Try to activate the domain var $URL = concat('http://',$HOST,':',$PORT) debug ' Inside GRDN module, activating the domain' call loadCommand(concat(lastCommand(),' -noSplash -application \ com.bea.support.guardian.ui.headless.Headless \ -gactivateDomain -t ',$URL,' -u ',$USER,' -p ',$pwd,\ @opt,' -data ',$WORKSPACE,' 2>&1'),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(concat(lastCommand(),' -noSplash -application \ com.bea.support.guardian.ui.headless.Headless \ -gevaluateDomainBundle -d ',\ $DOMAIN,' -b ',$BUNDLE,' -u ',$USER,' -p ',$pwd,\ ' -data ',$WORKSPACE,' 2>&1'),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, 2012, 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