# MCsundiag.ctl:258: Collects SunDiag Information # $Id: MCsundiag.ctl,v 1.5 2016/06/08 13:33:07 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCsundiag.ctl,v 1.5 2016/06/08 13:33:07 RDA Exp $ # # Change History # 20160608 DXM Changed path to sundiag and amended comments =head1 NAME EXPLORER:MCsundiag - Collects SunDiag Information =head1 DESCRIPTION Collects SunDiag information. =cut use Mrc # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('sundiag') #------------------------------------------------------------------------------ # XPLR_sundiag section #------------------------------------------------------------------------------ section XPLR_sundiag if !${B_GLOBAL:true} return call log_run('Processing SunDiag sections ...') =head2 SunDiag Information Collects SunDiag using F =cut debug ' Inside SunDiag collection' # Check tool exists, if yes proceed with execution logic if ?testFile('x',$cmd = '/opt/oracle.SupportTools/sundiag.sh') {pretoc '2: SunDiag' # Execute the command and collect the corresponding output report sundiag_cmd # Create a tmp buffer to hold stdout, required to discover output location var $tmp = newTemp('sundiag','.txt') # Construct command line to capture stdout in tmp buffer var $cmd = concat($cmd,' >',quote($tmp),' 2>&1') # RDA menu text title '---+!! SunDiag Information' prefix {write '---+ SunDiag Output' write '---## Using: ',encode($cmd) } # Execute command call command($cmd) # Load tmp buffer call loadFile($tmp) # Loop through every line and match on string which we expect to find # on the line before the line containing the output file location # When a match is found, loop to next line and extract file location var $flg = false loop $lin (getLines()) {if $flg { # Extract string using an offset to take into account the hardcoded text which precedes it var $fil =substr($lin,46) break } var $flg = match($lin,'==============================================================================') } if !$flg { echo 'No output file location found in SunDiag stdout' } } else {echo 'RDA did not find SunDiag' return } call unlinkTemp('sundiag') # Collect the result file report sundiag_fil # RDA menu text prefix {write '---+ SunDiag File' 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 Path*| *Size*|*Last Modified Date*|' } # Use explorer macro to capture output in a specified directory and filename # under the explorer collection if collectFile('sundiag/sundiag_output.tar.bz2',$fil) write '|[[../',last,'][_blank][',$fil,']] | ',getSize($fil),'|',\ getLastModify($fil,''),' |' # RDA menu text if isCreated(true) {write $TOP toc '3:[[',getFile(),'][rda_report][SunDiag Result File]]' } # Clean up: # Transfer output of sundiag to RDA collect directory and purge # We could purge the file directly, but this code construct offers possibility # to explore use of non platform specific purge macro. Or be a solution for # keeping the transferred file in RDA collect as an alternative place to manually # grab the file if $fil { # Extract filename var $src = basename($fil) # Transfer file from script output directory to RDA result set output / collect call transfer(dirname($fil),$src,${OUT.C},$src) call command(concat('rm -f ',catFile(${OUT.C},$src))) } # Adjust the table of content unpretoc =head1 SEE ALSO L, L =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