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 fail to find physical disk on Windows #351

Closed
giampaolo opened this issue May 23, 2014 · 14 comments
Closed

disk_io_counters fail to find physical disk on Windows #351

giampaolo opened this issue May 23, 2014 · 14 comments

Comments

@giampaolo
Copy link
Owner

From m.maly...@gmail.com on February 13, 2013 17:25:14

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: http://code.google.com/p/psutil/issues/detail?id=351

@giampaolo
Copy link
Owner Author

From g.rodola on February 26, 2013 03:01:08

Closing out as a duplicate of issue 234 .

Status: Duplicate
Labels: OpSys-Windows
Mergedinto: 234

@giampaolo
Copy link
Owner Author

From m.maly...@gmail.com on April 12, 2013 04:31:39

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.

Attachment: DISK_PERFORMANCE.patch

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 06:28:24

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?

Status: ReOpened
Labels: Milestone-0.7.0
Mergedinto:

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 07:09:42

Status: FixedInHG

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 11:21:27

Status: Fixed

@LeoCavaille
Copy link

Hey @giampaolo I am experiencing this issue with win server 2012 R2 64 bits, python 2.7.8, psutil 2.2.1.
Can we reopen this issue ?

  File "psutil\__init__.pyc", line 1726, in disk_io_counters
RuntimeError: couldn't find any physical disk

I'll try to get the bottom of it but you might have ideas?
Thanks

@giampaolo
Copy link
Owner Author

Not at the moment no, I'll have to investigate the original issue and code changes. Reopening for now.

@giampaolo giampaolo reopened this Feb 6, 2015
@giampaolo
Copy link
Owner Author

@LeoCavaille not sure if you're still into it but the issue is old so I wonder whether it still exists. Care to try?

@goofballtech
Copy link

Been working on getting influxDB working and just realized i am getting these as well on Windows Server 2016. Managed to stumble on your thread here. if you still need a fix tested (assumption since issue is still open) i am will to give it a shot.

Thanks.

capture

@ofek
Copy link
Contributor

ofek commented Oct 25, 2018

@giampaolo Hi there!

Any progress on this? We're hitting the same issue https://ci.appveyor.com/project/Datadog/integrations-core/builds/19775520#L342

@ofek
Copy link
Contributor

ofek commented Oct 25, 2018

Sorry for the noise, diskperf -y actually does make AppVeyor work.

@giampaolo
Copy link
Owner Author

It is necessary to issue diskperf -y command in order to make disk_io_counters() work? If so I will add it to the doc.

@ofek
Copy link
Contributor

ofek commented Oct 27, 2018

I think that is correct yes, at least on some newer versions of Windows Server.

@giampaolo
Copy link
Owner Author

Closing out as fixed (diskperf -y was documented).

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

4 participants