# DCgfs.ctl:316:Collects Oracle GlassFish Server Information # $Id: DCgfs.ctl,v 1.14 2015/08/13 20:52:13 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/DCgfs.ctl,v 1.14 2015/08/13 20:52:13 RDA Exp $ # # Change History # 20150813 MSC Eliminate Perl 5.22 warnings. =head1 NAME OFM:DCgfs - Collects Oracle GlassFish Server Information =head1 DESCRIPTION This module collects Oracle GlassFish Server-related information. The module covers Sun Java System Application Server (SJSAS) 8.x, 9.x, Oracle GlassFish Server Release 2.0 and later. The following reports can be generated and are regrouped under C: =head1 REPORTS =cut echo tput('bold'),'Processing OFM.GFS module ...',tput('off') # Initialization var $DOM_ROOT = ${D_DOMAIN_ROOT:''} var $GFS_HOME = ${D_HOME:''} var $NOD_ROOT = ${D_NODE_ROOT:''} var $TAIL = ${DFT.N_TAIL:1000} var $THREAD_DUMP = ${N_THREAD_DUMP:2} var $THREAD_DUMP_INT = ${N_THREAD_DUMP_INTERVAL:5} var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' pretoc '1:GlassFish Server' # Set the GFS symbol call setSymbol('$GFS_HOME',$GFS_HOME) # Load the common macros run RDA:library() # Determine the command path if ${OS.aix} {if ?findCommand('procmap') var $PMAP = last if ?findCommand('procstack') var $PSTACK = last } elsif ${OS.hpux} {if ?findCommand('pmap') var $PMAP = last if ?findCommand('pstack') # Itanium systems only var $PSTACK = last } elsif ${OS.linux} {if ?findCommand('pmap') var $PMAP = concat(last,' -x') if ?findCommand('pstack') var $PSTACK = last } elsif ${OS.solaris} {if ?findCommand('pmap') var $PMAP = concat(last,' -x') if ?findCommand('pstack') var $PSTACK = last } # Determine Java home path var $JAVA_HOME = undef if ?nvl(testFile('f',catFile($GFS_HOME,'glassfish','config','asenv.conf')),\ testFile('f',catFile($GFS_HOME,'config','asenv.conf'))) {if grepFile(last,'^AS_JAVA=(.*)$','f1') {if compare('EQ',\ pop(@dir = splitDir($JAVA_HOME = trim(first,"[\0x22\0x27]"))),'jre') var $JAVA_HOME = catDir(@dir) } } if !?$JAVA_HOME {if ?nvl(testFile('f',catFile($GFS_HOME,'glassfish','bin','jvmreport.out')),\ testFile('f',catFile($GFS_HOME,'bin','jvmreport.out'))) {if grepFile(last,'^java\.home\s*=\s*(.*)$','f1') {if compare('EQ',pop(@dir = splitDir($JAVA_HOME = first)),'jre') var $JAVA_HOME = catDir(@dir) } } } if !?$JAVA_HOME {if ?${ENV.JAVA_HOME} var $JAVA_HOME = last } =head2 abbr - Abbreviations Displays the RDA abbreviations defined for the GlassFish Server home collection. =cut debug ' Inside GFS module, collecting defined abbreviations' report abbr prefix {write '---+ GlassFish Server Home Abbreviations' write '|*Abbreviation*|*Location*|' } var %hsh = getSymbols() loop $key (keys(%hsh)) write '|',$key,' |',$hsh{$key},' |' if isCreated(true) toc '2:[[',getFile(),'][rda_report][Abbreviations]]' =head1 GLASSFISH SERVER INFORMATION =head2 version_info - Version Information Gathers Oracle GlassFish Server version information. =cut debug ' Inside GFS module, gathering version information' pretoc '2:Server Information' if ?testFile('f',catFile($GFS_HOME,'bin',${AS.BATCH:'asadmin'})) {var $ASA = lastTestCommand() report version_info prefix {write '---+ Oracle GlassFish Server Version Information' write '---## Using: ',encode($cmd) } if ?testDir('d',catDir($GFS_HOME,'glassfish')) {var $cmd = concat($ASA,' version --verbose --local') call writeCommand($cmd) } else {var $cmd = concat($ASA,' version --verbose') call writeCommand($cmd) } if isCreated(true) toc '3:[[',getFile(),'][rda_report][Version Information]]' } =head2 Configuration Files Gathers Oracle GlassFish Server-related configuration files. =cut if ?testDir('d',$GFS_HOME) {debug ' Inside GFS module, collecting the GlassFish configuration files' pretoc '3:Configuration Files' if ?nvl(testDir('d',catDir($GFS_HOME,'glassfish','config')),\ testDir('d',catDir($GFS_HOME,'config'))) call sort_files(4,0,grepDir(last,'^\.+$','pv')) unpretoc =head2 Log Files Gathers Oracle GlassFish Server-related log files. =cut debug ' Inside GFS module, collecting the GlassFish log files' pretoc '3:Log Files' call sort_shares('GFS_LOG',undef,4,$TAIL,\ grepDir($GFS_HOME,'^(Install|Sun)_','ip')) unpretoc } unpretoc =head1 DOMAIN INFORMATION =cut # Determine the thread dump command if ?testDir('d',catDir($GFS_HOME,'glassfish')) var $THREAD_CMD = \ concat($ASA,' generate-jvm-report %s --type=thread --target ') else var $THREAD_CMD = concat($ASA,' generate-jvm-report %s --type=thread ') # Macro to get the thread dump macro write_thread_dump {var ($nam,$cmd,$prt) = @arg import $THREAD_DUMP,$THREAD_DUMP_INT report concat('thread_dump_',$nam) prefix {write '---+ Thread Dumps (',$nam,')' 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*|' } var ($cnt,$max) = (0,$THREAD_DUMP) while $max {output c,concat('d_',$nam,incr($cnt)) if expr('==',$prt,4848) {if writeCommand(${CUR.O_LAST},replace($cmd,' --passwordfile=%s')) write '|[[',${CUR.O_LAST}->get_html(true),'][_blank][Dump ',$cnt,']]|' } else {var $adm = 'admin' if writeCommand(${CUR.O_LAST},\ {cmd => [$cmd,'2>&1'],\ pwf => ["AS_ADMIN_PASSWORD=%s\012",'pseudo','OFM:GFS',$adm,\ "Enter '${VAR.adm}' user password:",''],\ sap => true}) write '|[[',${CUR.O_LAST}->get_html(true),'][_blank][Dump ',$cnt,']]|' } end ${CUR.O_LAST} decr $max break !$max sleep $THREAD_DUMP_INT } if isCreated(true) toc '3:[[',getFile(),'][rda_report][Thread Dump]]' } # Iterate on each domain var $TMP = cond(isCygwin(), ${ENV.tmp:catDir(${ENV.LOCALAPPDATA},'Temp')},\ isWindows(),${ENV.TMP:catDir(${ENV.LOCALAPPDATA},'Temp')},\ ${ENV.TMP:'/tmp'}) loop $nam (@{T_DOMAINS:''}) {var ($dom,$pid) = (catDir($DOM_ROOT,$nam)) # Determine the process id if grepFile(catFile($dom,'config','pid'),'^(\d+)$','f1') var $pid = first if !?$pid {if grepFile(\ catFile($dom,'logs','jvm.log'),'\s+process=(\047)(\d+)\1\s+','f2') var $pid = first } debug ' Inside GFS module, analyzing domain ',$nam pretoc "2:'",$nam,"' Domain" # Collect JVM-related information if ?$pid run OFM:JVMinfo(3,last) =head2 Configuration Files Gathers domain-related configuration files. =cut debug ' - Collecting the domain configuration files' pretoc '3:Configuration Files' call sort_files(4,0,grepDir(catDir($dom,'config'),'^\.+$','pv')) unpretoc =head2 Message Queue Configuration Files Gathers message queue-related configuration files from domain. =cut debug ' - Collecting the domain message queue configuration files' pretoc '3:Message Queue Configuration Files' loop $dir (findDir(catDir($dom,'imq','instances'),'^\.+$','npv')) call sort_files(4,0,grepDir(catDir($dir,'props'),'^\.+$','pv')) unpretoc =head2 Application Files Gathers domain-related application files. =cut debug ' - Collecting the domain application files' pretoc '3:Application Files' call sort_files(4,0,grepDir(catDir($dom,'applications'),'\.xml$','dir')) unpretoc =head2 thread_dump - Thread Dump Gathers thread dumps at domain level. =cut debug ' - Collecting domain level thread dumps' if compare('ne',$nam,'agent') {var $prt = 4848 if ?testFile('f',catFile($dom,'config','domain.xml')) {var $obj = xmlLoadFile(last,xmlDisable(xmlParser(),'BCDEPR')) loop $xml (xmlFind($obj,'domain/configs/config name="^server-config$"')) {if xmlFind($xml,'network-config/network-listeners/network-listener \ name="^admin-listener$"') var $prt = isPort(xmlValue(last,'port'),true) elsif xmlFind($xml,'http-service/http-listener id="^admin-listener$"') var $prt = isPort(xmlValue(last,'port'),true) } } if ?$prt call write_thread_dump($nam,concat(sprintf($THREAD_CMD,\ concat('--port=',$prt,' --user=admin --passwordfile=%s')),'server'),$prt) } =head2 Log Files Gathers domain-related log files. =cut debug ' - Collecting the domain log files' var ($fcl,$gcl) = () if grepFile(catFile($dom,'config','domain.xml'),\ '\-XX:ErrorFile=(.*?)\<\/jvm-options\>','f1') var $fcl = \ trim(replace(first,'\$\{com\.sun\.aas\.instanceRoot\}',$dom),"[\042\047]") if !?testFile('fr',$fcl) {if grepDir($GFS_HOME,concat('^',$pid,'\.log$'),'fir') var $fcl = first(last) elsif grepDir($TMP,concat('^',$pid,'\.log$'),'fir') var $fcl = first(last) } if grepFile(catFile($dom,'config','domain.xml'),\ '\-Xloggc:(.*?)\<\/jvm-options\>','f1') var $gcl = \ trim(replace(first,'\$\{com\.sun\.aas\.instanceRoot\}',$dom),"[\042\047]") pretoc '3:Log Files' call sort_shares('GFS_LOG',undef,4,$TAIL,$fcl,$gcl,\ grepDir(catDir($dom,'logs'),'^\.+$','pv'),\ grepDir(catDir($dom,'logs','access'),'^\.+$','pv')) unpretoc =head2 Message Queue Log Files Gathers message queue-related log files from domain. =cut debug ' - Collecting the domain message queue log files' pretoc '3:Message Queue Log Files' loop $dir (findDir(catDir($dom,'imq','instances'),'^\.+$','npv')) call sort_shares('GFS_LOG',undef,4,$TAIL,\ grepDir(catDir($dir,'log'),'^\.+$','pv')) unpretoc 2 } =head1 INSTANCE INFORMATION =cut loop $itm (@{T_INSTANCES:''}) {var ($nod,$nam) = split(':',$itm) var ($ins,$pid) = (catDir($NOD_ROOT,$nod,$nam)) # Determine the process id if grepFile(catFile($ins,'config','pid'),'^(\d+)$','f1') var $pid = first if !?$pid {if grepFile(\ catFile($ins,'logs','jvm.log'),'\s+process=(\047)(\d+)\1\s+','f2') var $pid = first } debug ' Inside GFS module, analyzing instance ',$nam,' (',$nod,')' pretoc "2:'",$itm,"' Node:Instance" # Collect JVM-related information if ?$pid run OFM:JVMinfo(3,last) =head2 Configuration Files Gathers instance-related configuration files. =cut debug ' - Collecting the instance configuration files' pretoc '3:Configuration Files' call sort_files(4,0,grepDir(catDir($ins,'config'),'^\.+$','pv')) unpretoc =head2 Message Queue Configuration Files Gathers message queue-related configuration files from instance. =cut debug ' - Collecting the instance message queue configuration files' pretoc '3:Message Queue Configuration Files' loop $dir (findDir(catDir($ins,'imq','instances'),'^\.+$','npv')) call sort_files(4,0,grepDir(catDir($dir,'props'),'^\.+$','pv')) unpretoc =head2 thread_dump - Thread Dump Gathers thread dumps at instance level. =cut debug ' - Collecting instance level thread dumps' if compare('ne',$nam,'agent') call write_thread_dump($nam,concat(sprintf($THREAD_CMD,''),quote($nam))) =head2 Log Files Gathers instance-related log files. =cut debug ' - Collecting the instance log files' var ($fcl,$gcl) = () if grepFile(catFile($ins,'config','domain.xml'),\ '\-XX:ErrorFile=(.*?)\<\/jvm-options\>','f1') var $fcl = \ trim(replace(first,'\$\{com\.sun\.aas\.instanceRoot\}',$ins),"[\042\047]") if !?testFile('fr',$fcl) {if grepDir($GFS_HOME,concat('^',$pid,'\.log$'),'fir') var $fcl = first(last) elsif grepDir($TMP,concat('^',$pid,'\.log$'),'fir') var $fcl = first(last) } if grepFile(catFile($ins,'config','domain.xml'),\ '\-Xloggc:(.*?)\<\/jvm-options\>','f1') var $gcl = \ trim(replace(first,'\$\{com\.sun\.aas\.instanceRoot\}',$ins),"[\042\047]") pretoc '3:Log Files' call sort_shares('GFS_LOG',undef,4,$TAIL,$fcl,$gcl,\ grepDir(catDir($ins,'logs'),'^\.+$','pv'),\ grepDir(catDir($ins,'logs','access'),'^\.+$','pv')) unpretoc =head2 Message Queue Log Files Gathers message queue-related log files from instance. =cut debug ' - Collecting the instance message queue log files' pretoc '3:Message Queue Log Files' loop $dir (findDir(catDir($ins,'imq','instances'),'^\.+$','npv')) call sort_shares('GFS_LOG',undef,4,$TAIL,\ grepDir(catDir($dir,'log'),'^\.+$','pv')) unpretoc 2 } unpretoc =head1 SEE ALSO L, L =begin credits =over 10 =item RDA 4.26: Jeff Brown. =item RDA 8.00: Ramakrishnan Madaparambath. =item RDA 8.01: Georg Zigldrum. =item RDA 8.02: Ramakrishnan Madaparambath. =item RDA 8.03: Ramakrishnan Madaparambath, Daniel Mortimer. =item RDA 8.04: Ramakrishnan Madaparambath. =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