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

Different output of psutil.disk_partitions() vs psutil.disk_io_counters(perdisk=True) with respect to disk/device naming #942

Open
manuel-koch opened this issue Dec 5, 2016 · 7 comments

Comments

@manuel-koch
Copy link

On Windows 7 / Python 3.4 64bit the output of calls to
psutil.disk_partitions()
and
psutil.disk_io_counters(perdisk=True)
differs with respect to the underlying device / disk / drive information.

I.e. psutil.disk_partitions() returns device like "C:\"
but psutil.disk_io_counters(perdisk=True) returns disk key "PhysicalDrive0".
From OS perspective both are the same - but from user perspective there is no obvious connection between device "C:\" and disk "PhysicalDrive0".

It would be nice if disk_partitions() and disk_io_counters(perdisk=True) would use the same naming for the device / drive / disk, e.g. PhysicalDrive0

Looking at the package documentation of those two methods it seems the output is more misleading under Windows than under e.g. Linux.
The documentation uses e.g. device='/dev/sda1' and disk key 'sda1'.
Which looks similar but is still not the same !?

@giampaolo
Copy link
Owner

Mmm that's weird. Can you paste the actual output?

@manuel-koch
Copy link
Author

Here is the output of an interactive Python session on my PC :

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.__version__
'4.3.0'
>>> psutil.disk_partitions()
[sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'),
 sdiskpart(device='D:\\', mountpoint='D:\\', fstype='NTFS', opts='rw,fixed'),
 sdiskpart(device='E:\\', mountpoint='E:\\', fstype='', opts='cdrom'),
 sdiskpart(device='F:\\', mountpoint='F:\\', fstype='NTFS', opts='rw,fixed')]
>>> psutil.disk_io_counters(perdisk=True)
{'PhysicalDrive0': sdiskio(read_count=9553352, write_count=6458289, read_bytes=288282192896, write_bytes=257473859584, read_time=21438744350, write_time=7881456200),
 'PhysicalDrive1': sdiskio(read_count=1197379, write_count=2943595, read_bytes=37973087232, write_bytes=45277391360, read_time=953442370, write_time=254391130)}
>>>

Notice two things :

  • device and mountpoint are the same in output of disk_partitions() !?
  • device and drive-key from disk_io_counters() are unequal: "C:\" vs. "PhysicalDrive0"

I actually have two harddrives in use
Disk 0 : Two Partitions, C:\ and D:\
Disk 1 : One partition spanning whole disk, F:\

@giampaolo
Copy link
Owner

That's by design. Windows only lets you query IO counters based on physical disk, not partitions.
That is, if PhysicalDrive0 has two partitions, C:\ and D:\ (as is your case), you cannot filter IO activity only for C:\ or D:.

And yes, device and mountpoint on Windows are always the same string.
Maybe we can change that so the instead of device='C:\\' you get device='PhysicalDrive0', although I'm not sure whether it's possible.

@manuel-koch
Copy link
Author

manuel-koch commented Dec 5, 2016 via email

@giampaolo
Copy link
Owner

Looking back at this. I agree disk_partitions().device should be something like ""PhysicalDrive0" but I'm not sure how to convert "C:" to ""PhysicalDrive0".

@vishalekhe
Copy link

@giampaolo any update on this front?

@giampaolo
Copy link
Owner

Nope, I looked into it for a while and I don't know how to do it.

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

3 participants