# MCzfsc.ctl:251: Collects ZFS Configuration Information # $Id: MCzfsc.ctl,v 1.4 2015/10/06 17:05:43 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCzfsc.ctl,v 1.4 2015/10/06 17:05:43 RDA Exp $ # # Change History # 20151006 JGS Remove threadlist debug. =head1 NAME EXPLORER:MCzfsc - Collects ZFS Configuration Information =head1 DESCRIPTION This module collects information about ZFS file systems and pools. =cut use Mrc use Buffer # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('zfsconfig') #------------------------------------------------------------------------------ # XPLR_zfsc section #------------------------------------------------------------------------------ section XPLR_zfsc # Validate the execution context if or(not(${B_GLOBAL:1}),\ expr('<',get_osv(),10)) return if !and(defined(testFile('x','/usr/sbin/zpool')),\ defined(testFile('x','/usr/sbin/zfs')),\ defined(testFile('x','/usr/sbin/zdb'))) return log_error('Missing required ZFS binaries') call log_run('Processing ZFSC sections ...') # Define some module constants var $ZPOOL = '/usr/sbin/zpool' var $ZFS = '/usr/sbin/zfs' var $ZDB = '/usr/sbin/zdb' # Test if there are visible pools if $lim = getTimeout() call setTimeout(expr('*',$lim,3)) var @all = command($cmd = concat($ZPOOL,' list')) var @imp = command($cmd = concat($ZPOOL,' import')) var $flg = and(grep(@all,'no pools available','f'),\ not(grep(@imp,'^\s*pool: ','f'))) if $lim call setTimeout($lim) if $flg return log_info('No pools available') =head2 zfsc - ZFS information Gathers ZFS file system and pool information using the following commands: =over 2 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o Cdp_tx.tx_sync_thread | ::findstack -v" | /usr/bin/mdb -k> =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 =for stopwords Zpool Collects Zpool cache files also. =cut debug ' Inside ZFSC collection, generating file systems and pools report' # Perform the collection report zfsc title '---+!! ZFS File Systems and Pools' title $TOC var %pcf = () call do_exec(\ {cmd => 'TITLE',txt => '---+ ZFS File Systems'},\ ['disks/zfs/zfs_list',\ $ZFS,'list',\ '---++ All'],\ ['disks/zfs/zfs_list-t_snapshot',\ $ZFS,'list -t snapshot',\ '---++ Snapshots'],\ ['disks/zfs/zfs_list-t_volume',\ $ZFS,'list -t volume',\ '---++ Volumes'],\ ['disks/zfs/zfs_upgrade-v',\ $ZFS,'upgrade -v',\ '---++ Supported Versions'],\ {cmd => 'UNTITLE'},\ {cmd => 'TITLE',txt => '---+ ZFS Storage Pools'},\ {cmd => 'ARRAY',\ det => concat($ZPOOL,' list'),\ nam => 'disks/zfs/zpool_list.out',\ tbl => \@all,\ ttl => '---++ Pool List'},\ ['disks/zfs/zpool_status_-v',\ $ZPOOL,'status -v',\ '---++ Status'],\ ['disks/zfs/zpool_status_-x',\ $ZPOOL,'status -x',\ '---++ With Errors'],\ ['disks/zfs/zpool_iostat_-v',\ $ZPOOL,'iostat -v',\ '---++ I/O Statistics'],\ {cmd => 'ARRAY',\ det => concat($ZPOOL,' import'),\ nam => 'disks/zfs/zpool_import.out',\ tbl => \@imp,\ ttl => '---++ Available to Import'},\ ['disks/zfs/zpool_upgrade-v',\ $ZPOOL,'upgrade -v',\ '---++ Supported Versions'],\ {cmd => 'UNTITLE'}) # Process individual pools call shift(@all) # Discard the header line while ?shift(@all) {var ($nam) = match(last,'^(\S+)') var $arg = quote($nam) var @prp = command($cmd = concat($ZPOOL,' get all ',$arg)) call do_exec(\ {cmd => 'TITLE',txt => concat('---++ Pool: ',encode($nam))},\ [concat('disks/zfs/zpool_history_',$nam),\ $ZPOOL,concat('history ',$arg),\ '---+++ History'],\ [concat('disks/zfs/zpool_history-il_',$nam),\ $ZPOOL,concat('history -il ',$arg),\ '---+++ Long History'],\ {cmd => 'ARRAY',\ det => $cmd,\ nam => concat('disks/zfs/zpool_get_all_',$nam,'.out'),\ tbl => \@prp,\ ttl => '---+++ Properties'},\ [concat('disks/zfs/zfs_get_-rHp_all_',$nam),\ $ZFS,concat('get -rHp all ',$arg),\ '---+++ Dataset Properties'],\ {cmd => 'UNTITLE'}) # Extract the cache file from the pool properties loop $prp (@prp) {if match($prp,'cachefile\s*(\S+)') {var ($pcf{$nam}) = last break } } } # Share prepared values in settings for MCzfsd var $hsh = {} loop $lin (grep(@imp,'^\s*pool: ')) var $hsh->{replace($lin,'^\s*pool:\s+')} = 1 var ${RUN.EXPLORER.XPLR.ZFS.T_IMP_POOLS/T} = $hsh var ${RUN.EXPLORER.XPLR.ZFS.T_POOL_CACHE/T} = {%pcf} # Process mdb-related requests if ?$pgm = testFile('x','/usr/bin/mdb') {call do_exec(\ {cmd => 'TITLE',txt => '---+ Information through Modular Debugger'},\ ['disks/zfs/mdb/mdb-arc',$pgm,'-k',\ '---++ arc',\ {det => 'echo "::arc" | /usr/bin/mdb -k',\ req => {inp => "::arc\012",\ pre => "echo '::arc' |"}}],\ ['disks/zfs/mdb/mdb-zfs_params',$pgm,'-k',\ '---++ zfs_params',\ {det => 'echo "::zfs_params" | /usr/bin/mdb -k',\ req => {inp => "::zfs_params\012",\ pre => "echo '::zfs_params' |"}}],\ ['disks/zfs/mdb/mdb-spa',$pgm,'-k',\ '---++ spa',\ {det => 'echo "::spa" | /usr/bin/mdb -k',\ req => {inp => "::spa\012",\ pre => "echo '::spa' |"}}],\ ['disks/zfs/mdb/mdb-spa-v',$pgm,'-k',\ '---++ spa -v',\ {det => 'echo "::spa -v" | /usr/bin/mdb -k',\ req => {inp => "::spa -v\012",\ pre => "echo '::spa -v' |"}}],\ ['disks/zfs/mdb/mdb-spa-cv',$pgm,'-k',\ '---++ spa -cv',\ {det => 'echo "::spa -cv" | /usr/bin/mdb -k',\ req => {inp => "::spa -cv\012",\ pre => "echo '::spa -cv' |"}}],\ ['disks/zfs/mdb/mdb-kmastat',$pgm,'-k',\ '---++ kmastat',\ {det => 'echo "::kmastat" | /usr/bin/mdb -k',\ req => {inp => "::kmastat\012",\ pre => "echo '::kmastat' |"}}],\ ['disks/zfs/mdb/mdb-memstat',$pgm,'-k',\ '---++ memstat',\ {det => 'echo "::memstat" | /usr/bin/mdb -k',\ req => {inp => "::memstat\012",\ pre => "echo '::memstat' |"}}],\ ['disks/zfs/mdb/mdb-zfs_dbgmsg',$pgm,'-k',\ '---++ zfs_dbgmsg',\ {det => 'echo "::zfs_dbgmsg" | /usr/bin/mdb -k',\ req => {inp => "::zfs_dbgmsg\012",\ pre => "echo '::zfs_dbgmsg' |"}}],\ ['disks/zfs/mdb/mdb-spa_sync_thread_findstack',$pgm,'-k',\ '---++ spa sync_thread findstack',\ {det => 'echo "::walk spa | ::print spa_t spa_dsl_pool->\ dp_tx.tx_sync_thread | ::findstack -v" | /usr/bin/mdb -k',\ req => {inp => "::walk spa | ::print spa_t spa_dsl_pool->\ dp_tx.tx_sync_thread | ::findstack -v\012",\ pre => "echo '::walk spa | ::print spa_t spa_dsl_pool->\ dp_tx.tx_sync_thread | ::findstack -v' |"}}],\ ['disks/zfs/mdb/mdb-pgrep_zpool_findstack',$pgm,'-k',\ '---++ pgrep zpool findstack',\ {det => 'echo "::pgrep zpool | ::walk thread | ::findstack -v" | \ /usr/bin/mdb -k',\ req => {inp => "::pgrep zpool | ::walk thread | ::findstack -v\012",\ pre => "echo '::pgrep zpool | ::walk thread | \ ::findstack -v' |"}}],\ {cmd => 'UNTITLE'}) } # Add the report to the table of content if isCreated(true) toc '2:[[',getFile(),'][rda_report][ZFS File Systems and Pools]]' # Adjust the table of content unpretoc =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