# TLjrockt.ctl: Collects Oracle JRockit Process Information # $Id: TLjrockt.ctl,v 1.9 2015/08/21 15:30:22 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/TLjrockt.ctl,v 1.9 2015/08/21 15:30:22 RDA Exp $ # # Change History # 20150821 MSC Improve time consistency. =head1 NAME OFM:TLjrockt - Collects Oracle JRockit Process Information =head1 DESCRIPTION This tool collects information about an Oracle JRockit process. The tool covers Oracle JRockit R27 and later. For Oracle JRockit R28 and later, it collects the output of the following F command options: =over 4 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =back For Oracle JRockit R27, it collects the output of the following F command options: =over 4 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =back =head1 USAGE This tool can be used in two ways: =over 3 =item a) Runs interactively. It requests the user to enter the required information. -T jrockt run jrockt =item b) Runs from the command line. The input can be given in the command line using the following syntax: -T jrockt:|[||] run jrockt [ ] Where: is the process identifier of the Oracle JRockit process to analyze is the Oracle WebLogic Server domain home is the advanced mode for detailed report collection is the duration (in minutes) for collecting JRA data =back The tool collects Oracle JRockit data, generates reports, and displays key information about the results. The reports can be viewed in the C submenu of the final RDA output package also. If it is not disabled, you can refresh that section by the following command: -vCRP LOAD -v collect -RP LOAD =cut section tool if !match(${RDA.T_OS},'(cygwin|linux|solaris|MSWin32|MSWin64)') die 'Platform not supported' echo tput('bold'),'Collecting Oracle JRockit data ...',tput('off') # Set the abbreviation and purge old reports call setAbbr('OFM_JROCKIT_') call purge('E','.',15,0) # Get the arguments if match($arg[0],'\|') call unshift(@arg,split('\|',shift(@arg))) if @arg {var ($PID,$DOM,$ALL,$DUR) = last # Check the process identifier if !match($PID,'^\d+$') die 'Invalid or missing process identifier' # Validate the constants if !expr('>=',$DUR,0) var $DUR = 5 } else {call requestInput('TLjrockt') var $PID = ${RUN.REQUEST.N_PID} var $DOM = ${RUN.REQUEST.D_DOMAIN:''} var $ALL = ${RUN.REQUEST.B_ADVANCED:0} var $DUR = ${RUN.REQUEST.N_JRA_DURATION:5} } # Validate the domain and get the JRockit home if or(isWindows(),isCygwin()) {if loadFile(catFile($DOM,'bin','setDomainEnv.cmd')) {if grepLastFile('^\s*set\s+BEA_JAVA_HOME=.*?\s*$','f') var ($HOM) = match(last,'^\s*set\s+BEA_JAVA_HOME=(.*?)\s*$') } } elsif loadFile(catFile($DOM,'bin','setDomainEnv.sh')) {if grepLastFile('^[^\043]*\bBEA_JAVA_HOME=([\042\047]).*?\1','f') var (undef,$HOM) = match(last,'^[^\043]*\bBEA_JAVA_HOME=([\042\047])(.*?)\1') elsif grepLastFile('^[^\043]*\bBEA_JAVA_HOME=\S+','f') var ($HOM) = match(last,'^[^\043]*\bBEA_JAVA_HOME=(\S+)') } if !?$HOM die 'Invalid domain' # Initialization var $JRCMD = catCommand($HOM,'bin',${AS.EXE:'jrcmd'}) var ($REL) = match(pop(splitDir($HOM)),'jrockit_.*_R(\d+)\.') # Check for the release if expr('<',$REL,27) die 'The tool supports Oracle JRockit R27 and later' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' # Set the report prefix and initiate the result report call setPrefix(concat('p',$PID)) output E,result title '---+!! Oracle JRockit Data Collection' title $TOC title '---+ Parameters' title '|*Process Identifier*|',$PID,' |' title '|*Domain Home*|',encode($DOM),' |' title '|*JRockit Home*|',encode($HOM),' |' title '|*Advanced collection enabled?*|',cond($ALL,'Yes','No'),' |' if and($ALL,$DUR,expr('==',$REL,27)) title '|*JRA Recording Duration (minutes)*|',$DUR,' |' title $TOP # Get the JRockit related data debug ' - Gathering JRockit-related information using jrcmd' var @dat = (\ ['version', 'Version'],\ ['timestamp', 'Timestamp'],\ ['print_threads', 'Threads'],\ ['print_object_summary','Object Summary'],\ ['print_class_summary', 'Class Summary'],\ ['print_exceptions', 'Exceptions'],\ ['print_memusage', 'Memory Usage']) # Release specific options if expr('==',$REL,27) {if $ALL call push(@dat,['heap_diagnostics','Heap Diagnostics']) } else {call push(@dat,\ ['print_vm_state', 'VM State'],\ ['print_properties','Properties'],\ ['list_vmflags', 'VM Flags']) if $ALL {call push(@dat,\ ['hprofdump', 'hprof Dump'],\ ['heap_diagnostics','Heap Diagnostics']) } } # Get the jrcmd command output title '---+ jrcmd Command Output' loop $dat (@dat) {var ($opt,$ttl) = @{$dat} var $cmd = join(' ',$JRCMD,$PID,$opt) debug ' - Getting ',$opt,' data' prefix {write '---++ jrcmd ',$opt write '---### Using: ',encode($cmd) } call writeCommand(concat($cmd,' 2>&1')) if hasOutput(true) write $TOP } # Get the JRA recording output if and($ALL,$DUR,expr('==',$REL,27)) {debug 'Starting JRA recording ...' var $rpt = $[OUT]->add_report('e','recording',0,'.jra') var $fil = $rpt->get_file(true) var ($sec,$dur) = (60,expr('*',$DUR,60)) call system(concat($JRCMD,' ',$PID,' jrarecording recordingtime=',$dur,\ ' filename=',quote($fil))) sleep 10 # Extra time to sync var $max = time() incr $max,$dur while ?testFile('f',concat($fil,'.xml')) {echo ' - please wait (',$dur,' seconds remaining) ...' sleep $sec var $dur = $max decr $dur,time() break expr('<=',$dur,0) if expr('<',$dur,$sec) var $sec = $dur } prefix {write '---+ Recorded JRA' 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.' write '|*File Name*| *Size*|*Last Modification*|' } if ?testFile('s',$fil) {var $lnk = concat('[[',$rpt->get_raw(true),'][_blank][',encode($fil),']]') write '|',$lnk,'| ',getSize($fil),'|',getLastModify($fil,''),' |' } end $rpt if hasOutput(true) write $TOP } # Get the JRockit related dump file debug ' - Gathering JRockit-related dump file' prefix {write '---+ JRockit Dump Files' 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($DOM,'\.dump$','inp')) {var $siz = getSize($fil) var $nam = basename($fil) var $lnk = encode($nam) if $siz {var $rpt = $[OUT]->add_report('e',$nam,0,'.log') if $rpt->write_data($fil) var $lnk = concat('[[',$rpt->get_raw(true),'][_blank][',$lnk,']]') end $rpt } write '|',$lnk,' | ',$siz,'|',getLastModify($fil,''),' |' } if hasOutput(true) write $TOP # Render the report if isCreated(true) {call getGroupFile('D_CWD',renderFile()) dump 'Result file: ',last } else echo 'No information collected' =head1 SEE ALSO L =begin credits =over 10 =item RDA 4.23: Arun Boddapati. =item RDA 4.28: Arun Boddapati. =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