Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk_io_counters() is broken on Linux 2.4 #767

Closed
giampaolo opened this issue Feb 14, 2016 · 1 comment
Closed

disk_io_counters() is broken on Linux 2.4 #767

giampaolo opened this issue Feb 14, 2016 · 1 comment

Comments

@giampaolo
Copy link
Owner

Because /proc/diskstats has a different format, as explained here:
https://www.kernel.org/doc/Documentation/iostats.txt
Right now we fail with:

    ret = psutil.disk_io_counters()
  File "/home/giampaolo/svn/psutil/psutil/__init__.py", line 1799, in disk_io_counters
    rawdict = _psplatform.disk_io_counters()
  File "/home/giampaolo/svn/psutil/psutil/_pslinux.py", line 833, in disk_io_counters
    wbytes, wtime) = map(int, fields[3:11])
ValueError: invalid literal for int() with base 10: 'sda'
@giampaolo
Copy link
Owner Author

giampaolo commented Feb 14, 2016

It turns out the situation is even more confusing, and not properly handled at the moment.
The format of /proc/diskstats can have 3 variations. On Linux 2.4 each line has always 15 fields, e.g.:

3     0   8 hda 8 8 8 8 8 8 8 8 8 8 8

On Linux 2.6+ each line usually has 14 fields, and the disk name is in another position, like this:

3    0   hda 8 8 8 8 8 8 8 8 8 8 8

...unless (Linux 2.6) the line refers to a partition instead of a disk, in which case the line has less fields (7):

3    1   hda1 8 8 8 8

See:
https://www.kernel.org/doc/Documentation/iostats.txt
https://bugs.launchpad.net/percona-toolkit/+bug/897029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant