shanecode / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

disk_io_counters fail to find physical disk on Windows #351

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. import psutil
2. psutil.disk_io_counters(perdisk=True)

What is the expected output?
{'PhysicalDrive0': iostat(read_count=122927, write_count=200599, 
read_bytes=2346739200L, write_bytes=1753369088L, read_time=28560720L, 
write_time=9023350L)}

What do you see instead?
Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    psutil.disk_io_counters()
  File "C:\TestEnv\Python26\lib\site-packages\psutil\__init__.py", line 1041, in disk_io_counters
    raise RuntimeError("couldn't find any physical disk")
RuntimeError: couldn't find any physical disk

What version of psutil are you using? What Python version?
psutil 0.6.1
Python 2.6.6

On what operating system? Is it 32bit or 64bit version?
Windows Server 2008 32-bit

Please provide any additional information below.
I have run some additional commands:
>>> psutil.disk_partitions()
[partition(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'), 
partition(device='D:\\', mountpoint='D:\\', fstype='', opts='cdrom')]
>>> psutil.disk_usage('c:\\')
usage(total=146774487040L, used=93277802496L, free=53496684544L, 
percent=63.600000000000001)
>>> psutil._psmswindows.disk_io_counters()
{}

I also checked WinObj from sysinternals suite. It shows PhysicalDrive0 being 
symbolic link to \Device\Harddisk0\DR0, which exists and has type Device. 

I have similar machine hardware-wise, but with 64-bit Windows Server and 
additional iSCSI disk. On this machine psutil works without any issue.

Original issue reported on code.google.com by m.maly...@gmail.com on 13 Feb 2013 at 4:25

GoogleCodeExporter commented 9 years ago
Closing out as a duplicate of issue 234.

Original comment by g.rodola on 26 Feb 2013 at 11:01

GoogleCodeExporter commented 9 years ago
Probably not duplicate - after building with fix for issue 234, the problem 
still exists. Also, I always had PhysicalDrives numbered from 0. I found two 
things:

1. Disk statistics need to be turned on with 'diskperf -y' command executed 
from Windows cmd. Otherwise DeviceIoControl fails with ERROR_INVALID_FUNCTION.

2. MinGW has incorrect (old?) definition of DISK_PERFORMANCE structure. It is 
too short and DeviceIoControl fails with ERROR_INSUFFICIENT_BUFFER error.  As 
workaround, correct structure can be defined and passed to DeviceIoControl. 
Patch fixing this problem is attached.

Could you include 1. in the documentation? According to the web it is 
applicable to Windows Server versions 2003 and later.

Original comment by m.maly...@gmail.com on 12 Apr 2013 at 11:31

Attachments:

GoogleCodeExporter commented 9 years ago
I fixed 2) in revision 4d5b0de27024, thanks.
As for the issue per-se and issue 234 can we assume they are fixed if 'diskperf 
-y' command is executed first?

Original comment by g.rodola on 12 Apr 2013 at 1:28

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 12 Apr 2013 at 2:09

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 12 Apr 2013 at 6:21