()
return retdict
Return disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
Return disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
Return disk I / O statistics for every disk installed on the system as a dict of raw tuples .
def disk_io_counters():
    """Return disk I/O statistics for every disk installed on the
    system as a dict of raw tuples.
    """
    # man iostat states that sectors are equivalent with blocks and
    # have a size of 512 bytes since 2.4 kernels. This value is
    # needed to calculate the amount of disk I/O in bytes.
    SECTOR_SIZE = 512

    # determine partitions we want to look for
    partitions = []
    with open_text("/proc/partitions") as f:
        lines = f.readlines()[2:]
    for line in reversed(lines):
        _, _, _, name = line.split()
        if name[-1].isdigit():
            # we're dealing with a partition (e.g. 'sda1'); 'sda' will
            # also be around but we want to omit it
            partitions.append(name)
        else:
            if not partitions or not partitions[-1].startswith(name):
                # we're dealing with a disk entity for which no
                # partitions have been defined (e.g. 'sda' but
                # 'sda1' was not around), see:
                # https://github.com/giampaolo/psutil/issues/338
                partitions.append(name)
    #
    retdict = {}
    with open_text("/proc/diskstats") as f:
        lines = f.readlines()
    for line in lines:
        # http://www.mjmwired.net/kernel/Documentation/iostats.txt
        fields = line.split()
        if len(fields) > 7:
            _, _, name, reads, _, rbytes, rtime, writes, _, wbytes, wtime = \
                fields[:11]
        else:
            # from kernel 2.6.0 to 2.6.25
            _, _, name, reads, rbytes, writes, wbytes = fields
            rtime, wtime = 0, 0
        if name in partitions:
            rbytes = int(rbytes) * SECTOR_SIZE
            wbytes = int(wbytes) * SECTOR_SIZE
            reads = int(reads)
            writes = int(writes)
            rtime = int(rtime)
            wtime = int(wtime)
            retdict[name] = (reads, writes, rbytes, wbytes, rtime, wtime)
    return retdict
def disk_io_counters ( ) : # man iostat states that sectors are equivalent with blocks and # have a size of 512 bytes since 2.4 kernels. This value is # needed to calculate the amount of disk I/O in bytes. SECTOR_SIZE = 512 # determine partitions we want to look for partitions = [ ] with open_text ( "/proc/partitions" ) as f : lines = f . readlines ( ) [ 2 : ] for line in reversed ( lines ) : _ , _ , _ , name = line . split ( ) if name [ - 1 ] . isdigit ( ) : # we're dealing with a partition (e.g. 'sda1'); 'sda' will # also be around but we want to omit it partitions . append ( name ) else : if not partitions or not partitions [ - 1 ] . startswith ( name ) : # we're dealing with a disk entity for which no # partitions have been defined (e.g. 'sda' but # 'sda1' was not around), see: # https://github.com/giampaolo/psutil/issues/338 partitions . append ( name ) # retdict = { } with open_text ( "/proc/diskstats" ) as f : lines = f . readlines ( ) for line in lines : # http://www.mjmwired.net/kernel/Documentation/iostats.txt fields = line . split ( ) if len ( fields ) > 7 : _ , _ , name , reads , _ , rbytes , rtime , writes , _ , wbytes , wtime = fields [ : 11 ] else : # from kernel 2.6.0 to 2.6.25 _ , _ , name , reads , rbytes , writes , wbytes = fields rtime , wtime = 0 , 0 if name in partitions : rbytes = int ( rbytes ) * SECTOR_SIZE wbytes = int ( wbytes ) * SECTOR_SIZE reads = int ( reads ) writes = int ( writes ) rtime = int ( rtime ) wtime = int ( wtime ) retdict [ name ] = ( reads , writes , rbytes , wbytes , rtime , wtime ) return retdict