question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSX psutil.disk_usage confusion

See original GitHub issue

macOS 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:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
roachcord3commented, Oct 8, 2022

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

0reactions
roachcord3commented, Nov 18, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found