# WLSrun.def: Common Macros for Oracle WebLogic Server Runtime Information # $Id: WLSrun.def,v 1.14 2012/01/03 13:34:48 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/WLSrun.def,v 1.14 2012/01/03 13:34:48 mschenke Exp $ # # Change History # 20120103 MSC Change the copyright notice. =head1 NAME WLSrun - Defines Common Macros for Oracle WebLogic Server Runtime Information =head1 DESCRIPTION This persistent submodule regroups macros that are common to several Oracle WebLogic server runtime related-modules. The following macros are available: =cut # Make the module persistent and share macros keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('col_cluster','col_diag_images','col_log_exports',\ 'col_dom_config','col_dom_runtime',\ 'col_srv_config','col_srv_runtime',\ 'col_thread_dump') use Buffer # Load the common macros run WLSlib() =head2 S This macro collects domain-wide cluster management objects information (such as the number of C managed under the cluster). =cut macro col_cluster {var ($dom) = @arg debug ' - Inside WLSrun, gathering cluster information' set $cod {def getClusterNames(): " domainConfig() " return cmo.getClusters() " "def extractWlsCluster(clu,bas): " cd(clu) " print "---# RDA:BEGIN SECTION:4:'" + clu + "' Cluster" " print '---# RDA:BEGIN' " ls() " print "---# RDA:END MACRO MBean:5|Attributes|'"+clu+"' Topology \ Information ("+bas+')|'+pwd()+'|c_'+clu+'_clu_attributes' " print '---# RDA:BEGIN' " state(clu,'Cluster') " print "---# RDA:END REPORT:5|Status|'"+clu+"' Status Information \ ("+bas+')|'+pwd()+'|c_'+clu+'_clu_status' " print '---# RDA:BEGIN' " viewMBean(cmo) " print "---# RDA:END MACRO MBean:5|MBean|'"+clu+"' Configuration \ Information ("+bas+')|'+pwd()+'|c_'+clu+'_clu_bean' " cd('Servers') " print '---# RDA:BEGIN' " ls() " print "---# RDA:END MACRO MBean:5|Servers|'"+clu+"' Managed Servers \ Information ("+bas+')|'+pwd()+'|c_'+clu+'_clu_servers' " cd('..') " print '---# RDA:END SECTION' " cd('..') " "clusterNames = getClusterNames() "cd('Clusters') "print '---# RDA:BEGIN SECTION:3:Clusters' "for nam in clusterNames: " extractWlsCluster(nam.getName(),bas) " "print '---# RDA:END SECTION' "cd('..') " } call writeWas($cod,{bas => $dom}) } =head2 S This macro collects domain-wide configuration management objects information (such as C, C, C, C, C, C, and C). =cut macro col_dom_config {var ($dom,$PLUGIN) = @arg debug ' - Inside WLSrun, gathering domain configuration information' set $cod {print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:3|Domain Configuration|Domain Configuration \ Information ('+bas+')|'+pwd()+'|dom_config' "cd('Log') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|Domain Log Configuration|Domain Log \ Configuration Information ('+bas+')|'+pwd()+'|log_config' "cd('..') "cd('LogFilters') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|Log Filters Configuration|Domain Log \ Filters Configuration Information ('+bas+')|'+pwd()+'|log_filter_config' "cd('..') "cd('VirtualHosts') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|Virtual Hosts Configuration|Domain \ Virtual Hosts Configuration Information ('+bas+')|'+pwd()+\ '|virt_hst_config' "cd('..') "cd('JDBCSystemResources') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|JDBC System Resources Configuration|Domain \ JDBC System Resources Configuration Information ('+bas+')|'+pwd()+\ '|jdbc_config' "cd('..') "cd('JMSServers') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|JMS Servers Configuration|Domain JMS \ Servers Configuration Information ('+bas+')|'+pwd()+'|jms_svr_config' "cd('..') "cd('JMSSystemResources') "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|JMS System Resources Configuration|Domain \ JMS System Resources Configuration Information ('+bas+')|'+pwd()+\ '|jms_sys_config' "cd('..') " } loop $prd (keys($PLUGIN->{'WLS','dom'})) var $cod = join("\012",$cod,'',$PLUGIN->{'WLS','dom',$prd}) call writeWas($cod,{bas => $dom}) } =head2 S This macro collects domain-wide runtime management objects information (such as C, C, C, C, C, C, and C). =cut macro col_dom_runtime {var ($dom,$PLUGIN) = @arg import $TAIL,$WLST_DIR debug ' - Inside WLSrun, gathering domain runtime information' var $AS11 = and($WLST_DIR,\ grepDir(catDir($WLST_DIR,'wlst'),\ '^(oracledms|oracle-logging)\.py$','if')) set $cod {domainRuntime() "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:3|Domain Runtime|Domain Runtime \ Information ('+bas+')|'+pwd()+'|dom_runtime' "cd("LogRuntime/"+domainName) "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|Domain Log Runtime|Domain Log Runtime \ Information ('+bas+')|'+pwd()+'|log_runtime' "cd('../..') "cd("DomainServices") "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print '---# RDA:END MACRO MBean:4|Domain Services|Domain Services Runtime \ Information ('+bas+')|'+pwd()+'|dom_service' "cd('..') "if AS11 == 1: " print '---# RDA:BEGIN SECTION:4:Log Queries' " print '---# RDA:BEGIN' " displayLogs(last=1440,groupBy=['COMPONENT_ID','MODULE_ID','MSG_TYPE']) " print '---# RDA:END REPORT:5|Activities over last 24 Hours|Domain \ Activities over last 24 Hours ('+bas+')|'+pwd()+'|dom_odl_24h' " tb_cid = displayLogs(last=1440,groupBy="COMPONENT_ID",returnData=1) " for cid in tb_cid.keySet(): " try: " qry = 'COMPONENT_ID equals '+cid+\ ' and MSG_TYPE equals ERROR or MSG_TYPE equals WARNING' " print '---# RDA:BEGIN' " displayLogs(tail=TAIL,query=qry) " print '---# RDA:END REPORT:5|Last Warnings and Errors for '+cid+'|Domain \ Last Warnings and Errors for '+cid+' ('+bas+')|'+pwd()+\ '|dom_odl_com_'+cid " except: " pass " " print '---# RDA:END SECTION' " print '---# RDA:BEGIN' " dumpMetrics(format="raw") " print '---# RDA:END REPORT:4|dumpMetrics|Domain DMS Dump Metrics ('+bas+\ ')|'+pwd()+'|dom_dump_metrics' " " } loop $prd (keys($PLUGIN->{'WLS','domrun'})) var $cod = join("\012",$cod,'',$PLUGIN->{'WLS','domrun',$prd}) call writeWas($cod,{'+AS11',$AS11,\ '+TAIL',$TAIL,\ bas => $dom}) } =head2 S This macro collects server configuration management objects information. =cut macro col_srv_config {var (\%srv,$dom,$srv,$PLUGIN) = @arg debug ' - Inside WLSrun, gathering server configuration information' set $cod {import re " "def getConfigData(dir,ins,ttl,rpt,bas): " try: " cd(dir) " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print '---# RDA:END MACRO MBean:5|'+ttl+"|'"+ins+"' "+ttl+' Configuration \ Information ('+bas+')|'+pwd()+'|i_'+ins+'_'+rpt " cd('..') " except WLSTException,e: " pass " "print '---# RDA:BEGIN SECTION:3:Server Configuration' "cd("Servers") "for trg in ls('c',returnMap='true'): " if re.match(trg,ins,re.I): " srv=trg " cd(trg) " print '---# RDA:SET VARIABLE:WLS:'+ins+'="'+str(get('ListenPort'))+'"' " break "print '---# RDA:BEGIN' "ls() "print "---# RDA:END MACRO MBean:4|Attributes|'"+ins+"' Topology Information \ ("+bas+')|'+pwd()+'|i_'+ins+'_ins_attributes' "print '---# RDA:BEGIN' "state(srv,'Server') "print "---# RDA:END REPORT:4|Status|'"+ins+"' Status Information \ ("+bas+')|'+pwd()+'|i_'+ins+'_ins_status' "print '---# RDA:BEGIN' "viewMBean(cmo) "print "---# RDA:END MACRO MBean:4|MBean|'"+ins+"' Configuration Information \ ("+bas+')|'+pwd()+'|i_'+ins+'_ins_bean' "cd("Log/"+srv) "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print "---# RDA:END MACRO MBean:4|Server Log|'"+ins+"' Log Configuration \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_log' "getConfigData('LogFileFilter',ins,'Log File Filter','log_fil_filter',bas) "getConfigData('MemoryBufferFilter',ins,'Memory Buffer Filter',\ 'mem_buf_filter',bas) "getConfigData('StdoutFilter',ins,'Stdout Filter','std_out_filter',bas) "cd('../..') "cd("WebServer/"+srv) "print '---# RDA:BEGIN' "ls() "viewMBean(cmo) "print "---# RDA:END MACRO MBean:4|Web Server|'"+ins+"' Web Server \ Configuration Information ("+bas+')|'+pwd()+'|i_'+ins+'_web_server' "getConfigData("WebServerLog/"+srv,ins,'Web Server Log','web_svr_log',bas) "cd('../../../../..') "print '---# RDA:END SECTION' " } loop $prd (keys($PLUGIN->{'WLS','srv'})) var $cod = join("\012",$cod,'',$PLUGIN->{'WLS','srv',$prd}) call writeWas($cod,{bas => $dom,\ ins => $srv}) var %srv = getWasGroup('WLS') } =head2 S This macro collects server runtime management objects information. =cut macro col_srv_runtime {var ($dom,$srv,$PLUGIN) = @arg import $TAIL,$WLST_DIR debug ' - Inside WLSrun, gathering server runtime information' var $AS11 = and($WLST_DIR,\ grepDir(catDir($WLST_DIR,'wlst'),\ '^(oracledms|oracle-logging)\.py$','if')) set $cod {import re " "domainRuntime() "try: " cd("ServerRuntimes") " for trg in ls('c',returnMap='true'): " if re.match(trg,ins,re.I): " srv=trg " cd(srv) " break " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:3|Server Runtime|'"+ins+"' Server Runtime \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_runtime' " cd('ClusterRuntime') " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:4|Cluster Runtime|'"+ins+"' Cluster Runtime \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_clu_runtime' " cd('..') " cd("JDBCServiceRuntime/"+srv) " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:4|JDBC Service Runtime|'"+ins+"' JDBC \ Service Runtime Information ("+bas+')|'+pwd()+'|i_'+ins+\ '_svr_jdbc_runtime' " cd('../..') " cd("JMSRuntime/"+srv+".jms") " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:4|JMS Runtime|'"+ins+"' JMS Runtime \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_jms_runtime' " cd('../..') " cd("JVMRuntime/"+srv) " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:4|JVM Runtime|'"+ins+"' JVM Runtime \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_jvm_runtime' " cd('../..') " cd("LogRuntime/"+srv) " print '---# RDA:BEGIN' " ls() " viewMBean(cmo) " print "---# RDA:END MACRO MBean:4|Server Log Runtime|'"+ins+"' Log Runtime \ Information ("+bas+')|'+pwd()+'|i_'+ins+'_svr_log_runtime' " cd('../..') " if AS11 == 1: " print '---# RDA:BEGIN SECTION:4:Log Queries' " print '---# RDA:BEGIN' " displayLogs(target=srv,last=1440,\ groupBy=['COMPONENT_ID','MODULE_ID','MSG_TYPE']) " print "---# RDA:END REPORT:5|Activities over last 24 Hours|'"+ins+\ "' Activities over last 24 Hours ("+bas+')|'+pwd()+'|i_'+ins+\ '_odl_24h' " tb_cid = displayLogs(target=srv,last=1440,groupBy="COMPONENT_ID",\ returnData=1) " for cid in tb_cid.keySet(): " try: " qry = 'COMPONENT_ID equals '+cid+\ ' and MSG_TYPE equals ERROR or MSG_TYPE equals WARNING' " print '---# RDA:BEGIN' " displayLogs(tail=TAIL,query=qry) " print '---# RDA:END REPORT:5|Last Warnings and Errors for '+cid+"|'"+\ ins+"' Last Warnings and Errors for "+cid+' ('+bas+')|'+pwd()+\ '|i_'+ins+'_odl_com_'+cid " except: " pass " print '---# RDA:END SECTION' " print '---# RDA:BEGIN' " dumpMetrics(format="raw",servers=(srv)) " print "---# RDA:END REPORT:4|dumpMetrics|'"+ins+"' DMS Dump Metrics ("+\ bas+')|'+pwd()+'|i_'+ins+'_svr_dump_metrics' " " cd('../..') "except WLSTException,e: " pass " } loop $prd (keys($PLUGIN->{'WLS','srvrun'})) var $cod = join("\012",$cod,'',$PLUGIN->{'WLS','srvrun',$prd}) call writeWas($cod,{'+AS11',$AS11,\ '+TAIL',$TAIL,\ bas => $dom,\ ins => $srv}) } =head2 S This macro uses the Diagnostic Image Capture component of the Oracle WebLogic Diagnostic Framework (WLDF) to create a diagnostic snapshot or dump of a server's internal runtime state at the time of the capture. =cut macro col_diag_images {var ($dom,$srv,$hst,$prt,$usr,$pwd) = @arg import $RPT_DIRECTORY,$TIMEOUT debug ' - Inside WLSrun, capturing server diagnostic image' set $cod {timeout=0 "serverRuntime() "cd('WLDFRuntime/WLDFRuntime/WLDFImageRuntime/Image') "argTypes = jarray.array(['java.lang.String','java.lang.Integer'],\ java.lang.String) "argValues = jarray.array([rpt,timeout],java.lang.Object) "invoke('captureImage', argValues, argTypes) " } call setWasLogin($usr,$pwd,concat($hst,':',$prt)) call requestWas($cod,{bas => $dom,rpt => join('/',splitDir($RPT_DIRECTORY))}) if grepDir($RPT_DIRECTORY,\ concat('^diagnostic_image_',$srv,\ '_\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}\.zip$'),\ 'it') {var ($nam) = (last) data $nam var ($tim,$img) = ($TIMEOUT,getFile('.')) while expr('>',$tim,0) {sleep 5 if transfer($RPT_DIRECTORY,$nam,$RPT_DIRECTORY,$img) {report concat('i_',$srv,'_diag_image') write "---+ '",$srv,"' Diagnostic Image Data (",$dom,')' write '|*Image Name*|' write '|[[',$img,'][_blank][',$nam,']]|' write ' * 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.' toc '3:[[',getFile(),'][rda_report][Diagnostic Images]]' break } decr $tim,5 } } } =head2 S This macro gathers Oracle WebLogic Server-related log information. It executes a query against the specified log file and retrieves the exported Oracle WebLogic Diagnostic Framework (WLDF) data. RDA uses C in connected mode and C in off-line mode. The C collects data with the default options. =cut macro col_log_exports {var ($wls,$dom,$srv,$hst,$prt,$usr,$pwd) = @arg import $ADMIN,$LOG_AGE,$TYPE debug ' - Inside WLSrun, collecting log information' var %log = () var @tbl = ('EventsDataArchive','HarvestedDataArchive','ServerLog') if $wls {if compare('eq',$srv,$ADMIN) call push(@tbl,'DomainLog') } elsif ?$wls call push(@tbl,'ConnectorLog','DomainLog','JMSMessageLog','WebAppLog') else var @tbl = () if @tbl {loop $log (@tbl) {if compare('ne',$TYPE,'OFF') next and(compare('eq',$log,'DomainLog'),compare('ne',$srv,$ADMIN)) var $log = concat('i_',$srv,'_',$log) data $log var $log{$log} = getFile('/') } var @tbl = keys(%log) var $end = time() var $beg = expr('-',$end,expr('*',$LOG_AGE,86400)) var %fil = () var $str = concat('i_',$srv,'_') var $pat = quote($str) loop $log (grep(@tbl,quote($srv))) var $fil{replace($log{$log},'\\','/',true)} = replace($log,$pat) if $wls {set $cod {for pth in fil.keys(): " try: " exportDiagnosticDataFromServer(logicalName=fil[pth],exportFileName=pth,\ beginTimestamp=beg,endTimestamp=end) " except WLSTException,e: " pass " } var $cmd = 'exportDiagnosticDataFromServer' call setWasLogin($usr,$pwd,concat($hst,':',$prt)) call requestWas($cod,\ {'+beg',concat($beg,'000L'),'+end',concat($end,'000L'),fil => {%fil}}) } else {set $cod {for pth in fil.keys(): " try: " exportDiagnosticData(logicalName=fil[pth],exportFileName=pth) " except WLSTException,e: " pass " } var $cmd = 'exportDiagnosticData' call requestWas($cod,{fil => {%fil}}) } report concat($str,'log_info') prefix {write "---+ '",$srv,"' Log Exports (",$dom,')' write '---## Using: ',$cmd write '|*Exported Data*|' } loop $log (grep(@tbl,$pat)) {if testFile('s',$log{$log}) {var $nam = replace($log,$pat) write '|[[',basename($log{$log}),'][_blank][',$nam,']]|' } } if isCreated(true) {write ' * 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.' toc '3:[[',getFile(),'][rda_report][Log Exports]]' } } } =head2 S This macro gathers the thread dump information for the specified server. RDA uses C in connected mode. =cut macro col_thread_dump {var ($dom,$srv,$hst,$prt,$usr,$pwd) = @arg import $THREAD_DUMP,$THREAD_DUMP_INT debug ' - Inside WLSrun, gathering thread dump data' set $cod {print "---# RDA:BEGIN LIST" "for cnt in range(THREAD_DUMP): " java.lang.Thread.sleep(THREAD_DUMP_INT) " tim=str(java.util.Calendar.getInstance().getTimeInMillis()) " print '---# RDA:BEGIN' " threadDump(writeToFile='false') " print "---# RDA:END DATA:dump"+ins+'_'+tim+".dmp|i_"+ins+"_dump_"+tim "print "---# RDA:END LIST write_list:3|Thread Dump|'"+ins+"' Latest "+\ str(THREAD_DUMP)+' Thread Dumps ('+bas+')|Using: threadDump|i_'+ins+\ '_thread_dump' } call setWasLogin($usr,$pwd,concat($hst,':',$prt)) call writeWas($cod,{'+THREAD_DUMP',$THREAD_DUMP,\ '+THREAD_DUMP_INT',$THREAD_DUMP_INT,\ bas => $dom,\ ins => $srv}) } =head1 SEE ALSO L =begin credits =over 10 =item RDA 4.26: Wes Root, Maria Salzberger. =back =end credits =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