# MCsos.ctl:240: Collects sosreport Report # $Id: MCsos.ctl,v 1.2 2016/05/26 14:18:43 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCsos.ctl,v 1.2 2016/05/26 14:18:43 RDA Exp $ # # Change History # 20160526 PCW Housekeeping - remove output file from tmp directory =head1 NAME EXPLORER:MCsos - Collects F Report =head1 DESCRIPTION Collects sosreport output - must be executed as root, Linux only. =cut use Mrc # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('sos') #------------------------------------------------------------------------------ # XPLR_sos section #------------------------------------------------------------------------------ section XPLR_sos if !${B_GLOBAL:true} return call log_run('Processing SOS sections ...') =head2 sos - System Debugging Information Gathers system debugging information using the following command: =over 2 =item o C =back =cut debug ' Inside SOS collection, creating sosreport output file' if ?testFile('x',$cmd = '/usr/sbin/sosreport') {pretoc '2: System Configuration (sosreport)' # Execute the command report sos_cmd var $rpt = 'sosreport' var $tmp = newTemp('sos','.txt') var $cmd = concat($cmd,' --batch -k rpm.rpmva=off >',quote($tmp),' 2>&1') title '---+!! System Configuration Report' prefix {write '---+ sosreport Output' write '---## Using: ',encode($cmd) } call command($cmd) call loadFile($tmp) var $flg = false loop $lin (getLines()) {if $flg {var $fil = trim($lin) break } var $flg = match($lin,'^Your sosreport has been generated and saved in:$') } } else {echo 'RDA did not find /usr/sbin/sosreport' return } call unlinkTemp('sos') # Collect the result file var $src = basename($fil) report sos_fil prefix {write '---+ System Configuration (sosreport) Output 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*|' } if collectFile('sosreport/EXPL_SOS_sosreport.tar.xz',$fil) write '|[[../',last,'][_blank][',$fil,']] | ',getSize($fil),'|',\ getLastModify($fil,''),' |' if isCreated(true) {write $TOP toc '3:[[',getFile(),'][rda_report][sosreport Output File]]' } # Adjust the table of content unpretoc # Tidy up the file written to the temp directory, to avoid a # build-up of sosreport output files # Do this by moving / renaming the file into .../rda/output/collect # then removing it. if $fil { # Extract filename var $src = basename($fil) # Transfer file from script output directory to RDA output / collect call transfer(dirname($fil),$src,${OUT.C},$src) call command(concat('rm -f ',catFile(${OUT.C},$src))) } =head1 SEE ALSO L, 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