#NEWLINE# def iostat( zpool = None , sample_time = 0 ) : #NEWLINE# #INDENT# "\n    .. versionchanged:: 2016.3.0\n\n    Display I/O statistics for the given pools\n\n    zpool : string\n        optional name of storage pool\n    sample_time : int\n        seconds to capture data before output\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' zpool.iostat myzpool\n    " #NEWLINE# ret = OrderedDict ( ) #NEWLINE# zpool_cmd = _check_zpool ( ) #NEWLINE# cmd = '{zpool_cmd} iostat -v{zpool}{sample_time}' . format ( zpool_cmd = zpool_cmd , zpool = ( ' {0}' . format ( zpool ) if zpool else '' ) , sample_time = ( ' {0} 2' . format ( sample_time ) if sample_time else '' ) ) #NEWLINE# res = __salt__ [ 'cmd.run_all' ] ( cmd , python_shell = False ) #NEWLINE# if ( res [ 'retcode' ] != 0 ) : #NEWLINE# #INDENT# ret [ 'error' ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else res [ 'stdout' ] ) #NEWLINE# return ret #NEWLINE# #UNINDENT# header = [ 'pool' , 'capacity-alloc' , 'capacity-free' , 'operations-read' , 'operations-write' , 'bandwith-read' , 'bandwith-write' ] #NEWLINE# root_vdev = None #NEWLINE# vdev = None #NEWLINE# dev = None #NEWLINE# config_data = None #NEWLINE# current_pool = None #NEWLINE# for line in res [ 'stdout' ] . splitlines ( ) : #NEWLINE# #INDENT# if ( line . strip ( ) == '' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( line . startswith ( 'pool' ) and line . endswith ( 'write' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if line . endswith ( 'bandwidth' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( line . startswith ( '-' ) and line . endswith ( '-' ) ) : #NEWLINE# #INDENT# if config_data : #NEWLINE# #INDENT# ret [ current_pool ] = config_data #NEWLINE# #UNINDENT# config_data = OrderedDict ( ) #NEWLINE# current_pool = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( config_data , salt . utils . odict . OrderedDict ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# stat_data = OrderedDict ( ) #NEWLINE# stats = [ x for x in line . strip ( ) . split ( ' ' ) if ( x not in [ '' ] ) ] #NEWLINE# for prop in header : #NEWLINE# #INDENT# if ( header . index ( prop ) < len ( stats ) ) : #NEWLINE# #INDENT# if ( prop == 'pool' ) : #NEWLINE# #INDENT# if ( not current_pool ) : #NEWLINE# #INDENT# current_pool = stats [ header . index ( prop ) ] #NEWLINE# #UNINDENT# continue #NEWLINE# #UNINDENT# if ( stats [ header . index ( line ) ] == '-' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# stat_data [ prop ] = stats [ header . index ( prop ) ] #NEWLINE# #UNINDENT# #UNINDENT# dev = line . strip ( ) . split ( ) [ 0 ] #NEWLINE# if ( line [ 0 : 4 ] != '    ' ) : #NEWLINE# #INDENT# if ( line [ 0 : 2 ] == '  ' ) : #NEWLINE# #INDENT# vdev = line . strip ( ) . split ( ) [ 0 ] #NEWLINE# dev = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# root_vdev = line . strip ( ) . split ( ) [ 0 ] #NEWLINE# vdev = None #NEWLINE# dev = None #NEWLINE# #UNINDENT# #UNINDENT# if root_vdev : #NEWLINE# #INDENT# if ( not config_data . get ( root_vdev ) ) : #NEWLINE# #INDENT# config_data [ root_vdev ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( len ( stat_data ) > 0 ) : #NEWLINE# #INDENT# config_data [ root_vdev ] = stat_data #NEWLINE# #UNINDENT# #UNINDENT# if vdev : #NEWLINE# #INDENT# if ( vdev not in config_data [ root_vdev ] ) : #NEWLINE# #INDENT# config_data [ root_vdev ] [ vdev ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( len ( stat_data ) > 0 ) : #NEWLINE# #INDENT# config_data [ root_vdev ] [ vdev ] = stat_data #NEWLINE# #UNINDENT# #UNINDENT# if ( dev and ( dev not in config_data [ root_vdev ] [ vdev ] ) ) : #NEWLINE# #INDENT# config_data [ root_vdev ] [ vdev ] [ dev ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( len ( stat_data ) > 0 ) : #NEWLINE# #INDENT# config_data [ root_vdev ] [ vdev ] [ dev ] = stat_data #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ret