OSX psutil.disk_usage confusion
See original GitHub issuemacOS mojave 10.14: Python 3.6.5 psutil 5.4.8
When using psutil.disk_usage i get the following from a network SMB mount to Synology NAS:
>>> psutil.disk_usage('/Volumes/music')
sdiskusage(total=1348853272576, used=-2783315886080, free=4132169158656, percent=-206.3)
The df gives the following for the same mount:
//xxxxxx@SYNOSERVER._smb._tcp.local/music 11224413640 3154137584 8070276056 29% 1577068790 4035138028 28% /Volumes/music
As you can see, psutil is giving “-206.3 %” whereas it should be “28%”. Is this a known bug??
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
disk_usage() percent doesn't take reserved blocks ... - GitHub
Hi! As described here: NagiosEnterprises/ncpa#102 the disk usage differs between df command and psutil output. df -a Filesystem 1K-blocks ...
Read more >psutil 5.9.5 documentation
Return disk usage statistics about the partition which contains the given path as a named tuple including total, used and free space expressed...
Read more >How to get current disk IO and network IO into percentage ...
So your code to get disk usage percentage can look as follows p = psutil.Process() io_counters = p.io_counters() disk_usage_process ...
Read more >How to use the psutil.disk_usage function in psutil - Snyk
To help you get started, we've selected a few psutil.disk_usage examples, based on popular ways it is used in public projects.
Read more >mozilla-inbound: changeset 440523 ... - Mercurial
third_party/python/psutil-cp27-none-win_amd64/psutil/tests/test_osx.py ... -def disk_usage(path): - """Return disk usage statistics about the given *path* ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I know this is an old thread but I discovered this issue independently. There is a 32-bit overflow on the statvfs syscall on MacOS specifically. It can be worked around by using a different syscall. There’s an open issue tracked on Python itself for this, but I think technically psutil can do something about it, @giampaolo. The bug reporter has their own workaround they linked in the thread: https://github.com/sabnzbd/sabnzbd/blob/bdf7df9ecd10d600216072bae7e0da6fffb78b95/sabnzbd/filesystem.py#L961-L1005
@giampaolo never mind the bit about the negative number, I forgot that #2152 was recent enough to have not been in the release by the time I made my comment, but it has since been released, and after upgrading psutil I no longer get a negative number, however I do get inaccurate info regardless so I will open a new issue.