# MCsamf.ctl:252: Collects Information for SAM-FS Storage and Archive Management # $Id: MCsamf.ctl,v 1.7 2014/12/05 14:28:52 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCsamf.ctl,v 1.7 2014/12/05 14:28:52 RDA Exp $ # # Change History # 20141205 PRA Fix collection of /var/opt/SUNWsamfs/*. =head1 NAME EXPLORER:MCsamf - Collects SAM-FS Storage and Archive Management Information =head1 DESCRIPTION This module collects information about StorEdge SAM-FS Storage and Archive Management Information environments. =cut use Mrc # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' var $WRN = ' * 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.' run EXPLORER:XPLRlib('samfs') #------------------------------------------------------------------------------ # XPLR_samfs section #------------------------------------------------------------------------------ section XPLR_samfs # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing SAMF sections ...') if !or(is_pkg_installed('SUNWsamfs'),\ is_pkg_installed('SUNWqfs'),\ is_pkg_installed('SUNWsamfsr'),\ is_pkg_installed('SUNWqfsr'),\ is_pkg_installed('SUNWsamfsu'),\ is_pkg_installed('SUNWqfsu')) return log_info('SAM-FS or QFS not installed') # Define constants and store some variable values that will be always collected var $ETC = '/etc/opt/SUNWsamfs' var $EXE = '/opt/SUNWsamfs/sbin' var $BIN = '/opt/SUNWsamfs/bin' var $VAR = '/var/opt/SUNWsamfs' var %var = (\ ARCHDATA => concat('ARCHDATA = ',catDir($VAR,'archiver')),\ CATDIR => concat('CATDIR = ','/var/opt/SUNWsamfs/catalog'),\ ETCDIR => concat('ETCDIR = ',$ETC),\ EXECDIR => concat('EXECDIR = ',$EXE),\ STAGER_DATA => concat('STAGER_DATA = ',catDir($VAR,'stager')),\ TRCDIR => concat('TRCDIR = ',catDir($VAR,'trace')),\ TRCTMP => concat('TRCTMP = ',\ cond(defined($PID),\ catDir(${RUN.EXPLORER.D_TMP},concat($PID,'.trcctls')))),\ USERDIR => concat('USERDIR = ',$BIN),\ VARDIR => concat('VARDIR = ',$VAR)) =head2 samf - SAM-FS Storage and Archive Management Gathers SAM-FS Storage and Archive Management information. When a suitable C tool is present, it will collect: =over 2 =item o C =back Otherwise, the following commands will be collected: =over 2 =item o C<${EXECDIR}/archiver -lv> =item o C<${EXECDIR}/dmpshm> =item o C<${EXECDIR}/samcmd N ${SAMFS}> =item o C<${EXECDIR}/samcmd a ${FS}> =item o C<${EXECDIR}/samcmd d> =item o C<${EXECDIR}/samcmd f> =item o C<${EXECDIR}/samcmd l> =item o C<${EXECDIR}/samcmd m> =item o C<${EXECDIR}/samcmd n> =item o C<${EXECDIR}/samcmd p> =item o C<${EXECDIR}/samcmd r> =item o C<${EXECDIR}/samcmd s> =item o C<${EXECDIR}/samcmd u> =item o C<${EXECDIR}/samcmd v> =item o C<${EXECDIR}/samcmd w> =item o C<${EXECDIR}/samfsinfo ${FS}> =item o C<${EXECDIR}/samset debug> =item o C<${EXECDIR}/samset devlog all> =item o C<${EXECDIR}/samset> =item o C<${EXECDIR}/samsharefs ${FS}> =item o C<${EXECDIR}/samsharefs -R ${FS}> =item o C<${EXECDIR}/samtrace -v> =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 =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 =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 =item o C =item o C =back Collects also the following files: =over 2 =item o Last 1000 lines of F<${RECYCLER}> =item o Last 1000 lines of F<${RELEASER}> =item o Last 1000 lines of F<${SAMLOGD}> =item o Last 1000 lines of F<${STAGER}> =item o Last 1000 lines of F<${SAMFS}> =item o Last 1000 lines of F =item o F =item o F =item o F =item o F =item o F =item o F =back =cut debug ' Inside SAMF collection, gathering storage and archive information' report samf title '---+!! SAM-FS Storage and Archive Management' title $TOC # Get commands and files that will be collected regardless of samexplorer usage var @fil = (\ ['samfs/etc/opt/SUNWsamfs','/etc/opt/SUNWsamfs',undef,undef,'^\.+$','drv'],\ ['samfs/var/opt/SUNWsamfs','/var/opt/SUNWsamfs',undef,undef,'^\.+$','drv']) var @cmd = (\ {cmd => 'HASH',\ nam => 'samfs/variables.out',\ tbl => \%var,\ ttl => '---+ SAM-FS Variables'}) # Check for availability of samexplorer tool if and(testFile('x','/opt/SUNWsamfs/sbin/samexplorer'),\ or(compare('VALID',get_pkg_version('SUNWsamfsu'),'4.6'),\ compare('VALID',get_pkg_version('SUNWqfsu'), '4.6'))) {var $box = cleanBox() var ($nam) = command(concat(check(${RDA.T_OS},'solaris','/usr/bin/uname',\ '/bin/uname'),' -n')) var $fil = concat('SAMreport.',$nam,'.',localtime('%Y%m%d.%H%M%Z')) call push(@cmd,\ ['samfs/samexplorer',\ '/opt/SUNWsamfs/sbin/samexplorer',catCommand($box,$fil),\ '---+ Samexplorer Execution Report']) # Collect commands call do_exec(@cmd) # Collect samexplorer results tar file var $fil = concat($fil,'.tar.gz') if getSize(catFile($box,$fil)) {var ($lnk) = collectData(concat('samfs/',$fil),lastFile(),\ ['C',concat('samexplorer results (',$fil,')')]) write '---+ Samexplorer Results' write $WRN write '|*Result*|' write '|[[../',$lnk,'][_blank][',encode($fil),']]|' write $TOP } } else {call log_warning('samexplorer missing or not executable. \ Running legacy samfs script') # Define additional variables to search for its value var %nam = (\ 'archiver.cmd' => 'ARCHLOGS',\ 'recycler.cmd' => 'RECLLOGS',\ 'releaser.cmd' => 'RELLOG',\ 'samlogd.cmd' => 'STAGELOG',\ 'sam-amld' => 'AMLTRC',\ 'sam-archiverd' => 'ARCHTRC',\ 'sam-catserverd' => 'CATTRC',\ 'sam-clientd' => 'CLITRC',\ 'sam-fsd' => 'FSDTRC',\ 'sam-ftpd' => 'FTPTRC',\ 'sam-recycler' => 'RCYTRC',\ 'sam-rftd' => 'RFTTRC',\ 'sam-serverd' => 'SVRTRC',\ 'sam-sharefsd' => 'SHFSTRC',\ 'sam-stagerd' => 'STGTRC',\ 'stager.cmd' => 'STAGER_LOG') # Store additional variables to %var hash with its found value, or undef var $var{'DEVLOGS'} = concat('DEVLOGS = ',catFile($VAR,'devlog','*')) var @lin = command(join(' ',catCommand($EXE,'samcmd'),'d')) loop $key (keys(%nam)) {if match($key,'\.cmd$') {if ?testFile('f',catFile($ETC,$key)) {var $fil = value(grepFile(lastFile(),'logfile.*=','f')) # Prepare tail commands for selected log files if compare('ne',$key,'archiver.cmd') call push(@fil,\ {cmd=>'TAIL',nam=>concat('samfs',$fil),fil=>$fil,cnt=>'1000'}) } else var $fil = undef } else {var (undef,$fil) = split('\s+',grep(@lin,concat('^\s*',$key,'\s+'),'f'),2) next match($fil,'^off$') } var $var{$nam{$key}} = concat($nam{$key},' = ',$fil) } # Push additional files to collect call push(@fil,\ ['samfs/etc/driver_classes', '/etc/driver_classes'],\ ['samfs/etc/driver_aliases', '/etc/driver_aliases'],\ ['samfs/opt/SUNWsamfs/include/version.h','/opt/SUNWsamfs/include/version.h']) # Store commands call push(@cmd,\ {cmd => 'TITLE',txt => '---+ File Lists'},\ ['samfs/dev/dsk__2-ls-l',\ '/usr/bin/ls','-l /dev/dsk/*s2',\ '---++ /dev/dsk/*s2'],\ ['samfs/dev/dsk__2-ls-Ll',\ '/usr/bin/ls','-Ll /dev/dsk/*s2',\ '---++ /dev/dsk/*s2 (-Ll)'],\ ['samfs/dev/rdsk__2-ls-l',\ '/usr/bin/ls','-l /dev/rdsk/*s2',\ '---++ /dev/rdsk/*s2'],\ ['samfs/dev/rdsk__2-ls-Ll',\ '/usr/bin/ls','-Ll /dev/rdsk/*s2',\ '---++ /dev/rdsk/*s2 (-Ll)'],\ ['samfs/dev/rdst-ls-l',\ '/usr/bin/ls','-l /dev/rdst*',\ '---++ /dev/rdst*'],\ ['samfs/dev/rdst-ls-Ll',\ '/usr/bin/ls','-Ll /dev/rdst*',\ '---++ /dev/rdst* (-Ll)'],\ ['samfs/dev/samrd-ls-l',\ '/usr/bin/ls','-l /dev/samrd',\ '---++ /dev/samrd'],\ ['samfs/dev/samst-ls-l',\ '/usr/bin/ls','-l /dev/samst',\ '---++ /dev/samst'],\ ['samfs/dev/samst-ls-Ll',\ '/usr/bin/ls','-Ll /dev/samst',\ '---++ /dev/samst (-Ll)'],\ ['samfs/etc/driver_aliases-ls-l',\ '/usr/bin/ls','-l /etc/driver_aliases',\ '---++ /etc/driver_aliases'],\ ['samfs/etc/driver_classes-ls-l',\ '/usr/bin/ls','-l /etc/driver_classes',\ '---++ /etc/driver_classes'],\ ['samfs/etc/release-ls-l',\ '/usr/bin/ls','-l /etc/release',\ '---++ /etc/release'],\ ['samfs/opt/SANergy/lib-ls-l',\ '/usr/bin/ls','-l /opt/SANergy/lib',\ '---++ /opt/SANergy/lib'],\ ['samfs/opt/SANergy/lib_sparcv9-ls-l',\ '/usr/bin/ls','-l /opt/SANergy/lib/sparcv9',\ '---++ /opt/SANergy/lib/sparcv9'],\ ['samfs/opt/SANergy/lib-ls-Ll',\ '/usr/bin/ls','-Ll /opt/SANergy/lib',\ '---++ /opt/SANergy/lib (-Ll)'],\ ['samfs/opt/SANergy/lib-ls-Ll',\ '/usr/bin/ls','-Ll /opt/SANergy/lib/sparcv9',\ '---++ /opt/SANergy/lib/sparcv9 (-Ll)'],\ ['samfs/opt/SUNWsamfs-ls-lR',\ '/usr/bin/ls','-lR /opt/SUNWsamfs',\ '---++ /opt/SUNWsamfs'],\ ['samfs/var/adm/log/fs_fifo_log-ls-l',\ '/usr/bin/ls','/var/adm/log/fs_fifo_log',\ '---++ /var/adm/log/fs_fifo_log'],\ ['samfs/var/adm/log/fs_ictl_log-ls-l',\ '/usr/bin/ls','/var/adm/log/fs_ioctl_log',\ '---++ /var/adm/log/fs_ioctl_log'],\ {cmd => 'UNTITLE'}) var $pgm = catFile($EXE,'samset') call push(@cmd,\ {cmd => 'TITLE',txt => '---+ Samset Commands'},\ ['samfs/samset/samset' ,$pgm,undef ,'---++ All'],\ ['samfs/samset/samset-debug' ,$pgm,'debug' ,'---++ Debug'],\ ['samfs/samset/samset-devlog-all',$pgm,'devlog all','---++ All Devlog'],\ {cmd => 'UNTITLE'}) var $pgm = catFile($EXE,'samcmd') call push(@cmd,\ {cmd => 'TITLE',txt => '---+ Samcmd Commands'},\ ['samfs/samcmd/samcmd-d',$pgm,'d','---++ Option d'],\ ['samfs/samcmd/samcmd-f',$pgm,'f','---++ Option f'],\ ['samfs/samcmd/license' ,$pgm,'l','---++ Option l'],\ ['samfs/samcmd/samcmd-m',$pgm,'m','---++ Option m'],\ ['samfs/samcmd/samcmd-n',$pgm,'n','---++ Option n'],\ ['samfs/samcmd/samcmd-p',$pgm,'p','---++ Option p'],\ ['samfs/samcmd/samcmd-r',$pgm,'r','---++ Option r'],\ ['samfs/samcmd/samcmd-s',$pgm,'s','---++ Option s'],\ ['samfs/samcmd/samcmd-u',$pgm,'u','---++ Option u'],\ ['samfs/samcmd/samcmd-v',$pgm,'v','---++ Option v'],\ ['samfs/samcmd/samcmd-w',$pgm,'w','---++ Option w'],\ {cmd => 'UNTITLE'}) # Find the samfs log file location var $val = 'local7' if ?testFile('fr','/etc/opt/samfs/defaults.conf') {loop $lin (grepFile('/etc/opt/samfs/defaults.conf','^\s*#','v')) {next !match($lin,'LOCAL') var ($val) = match($lin,'^.*LOG_(\S+)') break } } # Push for tail samfs log file, and /tmp/.grau file if ?testFile('f','/etc/syslog.conf') {loop $lin (grepCommand('/usr/ccs/bin/m4 /etc/syslog.conf 2>/dev/null',\ $val,'i')) {var ($fil) = match($lin,'^[^#].*\s(\S+)$') next match($fil,'^[^\/]|\/dev|\*') call push(@fil,\ {cmd=>'TAIL',nam=>concat('samfs',$fil),fil=>$fil,cnt=>'1000'}) break } } call push(@fil,\ {cmd=>'TAIL',nam=>'samfs/tmp/.grau',fil=>'/tmp/.grau',cnt=>'1000'}) call push(@cmd,\ {cmd => 'TITLE',txt => '---+ SAM-FS Filesystems Information'}) loop $lin (grepFile('/etc/vfstab','^\s*#','v')) {var ($dev,undef,$dir,$val) = split('\s+',$lin,5) next !compare('eq',$val,'samfs') call push(@cmd,\ concat('---++ ',$dev),\ [concat('samfs/samfsinfo/',replace($dev,'\/')),\ catFile($EXE,'samfsinfo'),quote($dev)],\ [concat('samfs/samsharefs/',replace($dev,'\/')),\ catFile($EXE,'samsharefs'),quote($dev)],\ [concat('samfs/samsharefs-R/',replace($dev,'\/')),\ catFile($EXE,'samsharefs'),concat('-R ',quote($dev))],\ [concat('samfs/samcmd/samcmd-a/',replace($dev,'\/')),\ catFile($EXE,'samcmd'),concat('a ',quote($dev))],\ [concat('samfs/samcmd/samcmd-N',$dir),\ catFile($EXE,'samcmd'),concat('N ',quote($dir))]) } call push(@cmd,\ ['samfs/usr/lib/fs/samfs/sam-fsd-v',\ '/usr/lib/fs/samfs/sam-fsd','-v','---++ Daemon'],\ {cmd => 'UNTITLE'}) # Get SAM_FS daemon process tree if and(testFile('f','/usr/proc/bin/pstack'),\ testFile('f','/usr/proc/bin/pflags'),\ testFile('f','/usr/proc/bin/ptree')) {var ($pid) = grepCommand('/usr/bin/ps -e', '^\s*(\d+).*sam-fsd$','1f') if $pid {if @lin = command(concat('/usr/proc/bin/ptree ',$pid)) {call push(@cmd,\ '---+ SAM-FS Daemon Process',\ {cmd => 'ARRAY',nam => concat('samfs/proc/ptree/sam_fsd.tree.',$pid),\ det => concat('/usr/proc/bin/ptree ',$pid),\ tbl => \@lin,\ ttl => '---++ SAM-FS Daemon Process Tree'}) loop $lin (@lin) {var ($pid) = match($lin,'^\s*(\d+)') call push(@cmd,\ concat('---++ Process ',$pid,' Details'),\ [concat('samfs/proc/pstack/sam_fsd.stack.',$pid),\ '/usr/proc/bin/pstack',$pid,\ '---+++ Stack Trace'],\ [concat('samfs/proc/pflags/sam_fsd.flags.',$pid),\ '/usr/proc/bin/pflags',$pid,\ '---+++ Tracing Flags']) } } } } var $flg = and(expr('>',get_osv(),7),\ testFile('f','/usr/proc/bin/pstack'),\ testFile('f','/usr/proc/bin/pflags')) loop $dir ($ETC,$VAR,$BIN,$EXE) {if ?testDir('drx',$dir) {if @lin = command(concat('/usr/bin/find ',$dir,\ ' -follow -name "core*" -type f -print')) {call push (@cmd,concat('---+ Core Files from ',encode($dir))) loop $fil (@lin) {var $arg = quote($fil) call push(@cmd,\ concat('---++ Core File ',encode($fil)),\ [concat('samfs/core/',$fil,'-ls-tlLd'),\ '/usr/bin/ls',concat('-tlLd ',$arg),\ '---+++ List Characteristics'],\ [concat('samfs/core/',$fil,'-file'),\ '/usr/bin/file',$arg,\ '---+++ File Type']) if $flg call push(@cmd,\ [concat('samfs/core/pstack_',$fil),\ '/usr/proc/bin/pstack',$arg,\ '---+++ Stack Trace'],\ [concat('samfs/core/pflags_',$fil),\ '/usr/proc/bin/pflags',$arg,\ '---+++ Tracing Flags']) } } } } if ?testFile('f',catFile($ETC,'mcf')) {var (%cat,%unk) = () call push(@cmd,{cmd => 'TITLE',txt => '---+ Catalog Dumps'}) loop $lin (grepFile(lastFile(),'^#|^\s*$','v')) {var (undef,$num,$typ,$grp,undef,$dir) = split('\s+',trim($lin),6) next match($typ,'^(g\d.*|gx|m[admrs]|rd|s[cs]|z.)$') if match($typ,\ '^(a[123cdels]|cy|d[ms]|e[8b]|fj|gr|h[cpy]|i[clm]|m[el]|pd|q8|rb|s[9kl])$') {if compare('ne',$dir,'-') var $pth = cond(isAbsolute($dir),$dir,\ catDir('/var/opt/SUNWsamfs/catalog',$dir)) else var $pth = catDir('/var/opt/SUNWsamfs/catalog',$grp) var $cat{$typ,$pth} = 1 } elsif match($typ,\ '^(at|d[23t]|fd|i[7b]|l[it]|m[fo]|o[2d]|pe|s[aefgot]|tp|vt|wo|x[mt])$') {var $pth = catDir('/var/opt/SUNWsamfs/catalog',concat('man',$num)) var $cat{$typ,$pth} = 1 } else var $unk{$typ} = 1 } loop $typ (keys(%cat)) {loop $pth (keys($cat{$typ})) {call push(@cmd,\ [concat('samfs/dump_cat/',$typ,'_dump_cat-V'),\ '/opt/SUNWsamfs/sbin/dump_cat',concat('-V ',quote($pth)),\ concat('---++ Type [',$typ,'] for ',$pth),\ {out=>{mod=>true,cat=>'T'}}]) if compare('eq',$typ,'hy') call push(@cmd,\ [concat('samfs/dump_cat/',$typ,'_historian_dump_cat-V'),\ '/opt/SUNWsamfs/sbin/dump_cat',concat('-V ',quote($pth)),\ concat('---++ Type [',$typ,'] for ',$pth),\ {out=>{mod=>true,cat=>'T'}}]) } } loop $typ (keys(%unk)) call push(@cmd,\ [concat('samfs/dump_cat/',$typ,'_unknown_equipment_type'),\ undef,'Unknown equipment type',\ concat('---++ Unknown Equipment Type [',$typ,']')]) call push(@cmd,{cmd => 'UNTITLE'}) } call push(@cmd,\ '---+ Miscellaneous Commands',\ [concat('samfs',$ETC,'/archiver-lv'),\ catFile($EXE,'archiver'),'-lv',\ '---++ Archiver'],\ [concat('samfs',$ETC,'/archiver.cmd-grep-wait'),\ '/usr/bin/grep',concat('wait ',catFile($ETC,'archiver.cmd')),\ '---++ "wait" on archiver.cmd'],\ ['samfs/name_to_sysnum_grep',\ '/usr/bin/grep','sam /etc/name_to_sysnum',\ '---++ "sam" on /etc/name_to_sysnum'],\ ['samfs/system/sam_statvfs_bias-grep',\ '/usr/bin/grep','sam_statvfs_bias /etc/system',\ '---++ "sam_statvfs_bias" on /etc/system'],\ ['samfs/dmpshm',\ catFile($EXE,'dmpshm'),undef,\ '---++ Shared Memory Segments'],\ [concat('samfs',$EXE,'/samtrace-v'),\ catFile($EXE,'samtrace'),'-v',\ '---++ Trace']) if ?testFile('rx','/opt/SUNWsamfs/jre/bin/jre') call push(@cmd,\ ['samfs/opt/SUNWsamfs/jre/bin/jre-v',\ '/opt/SUNWsamfs/jre/bin/jre','-v',\ '---++ SAM-FS JRE Version']) # Collect commands stored so far call do_exec(@cmd) # Store the modinfo output lines matching the needed values if @res = grepCommand('/usr/sbin/modinfo','sam| sd | st |fp|qlc|ssd') {call do_exec({cmd => 'TITLE',txt => '---+ Loaded Kernel Modules'}) loop $pat ('sam',' sd ',' st ','fp','qlc','ssd') {var @lin = grep(@res,$pat) if compare('eq',$pat,'sam') var @lin = grep(@lin,'sampling','v') if @lin call do_exec(\ {cmd => 'ARRAY',\ det => concat('/usr/sbin/modinfo | /usr/bin/grep "',$pat,'"'),\ nam => concat('samfs/modinfo/modinfo_grep-',\ check($pat,'sam','sam-v-sampling',trim($pat)),\ '.out'),\ tbl => \@lin,\ ttl => concat('---++ "',trim($pat),'" Modules')}) } call do_exec({cmd => 'UNTITLE'}) } } # Collect files prefix {write '---+ Collected files' write $WRN write '|*File Path*| *Size*|*Last Modified Date*|' } call do_collect_fil(@fil) if hasOutput(true) write $TOP # Add the report to the table of content if isCreated(true) toc '2:[[',getFile(),'][rda_report][SAM-FS Storage and Archive Management]]' =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