-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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_usage() percent doesn't take reserved blocks into account (-5%) #829
Comments
psutil metrics are expressed in bytes, while df should show kb. As for the
|
|
Mostly interested in the % since that doesn't give the proper percentage when it doesn't account for the reserved blocks. Do you know of any good way to account for this? Is it always 5% off? |
So here's my findings. Linux (not sure about other UNIXes) by default reserves 5% of total disk space for the root user so that if, say, the user home directory fills the disk, the root user and the system will still have 5% of space to write into /var/log, not crash in general and also to avoid disk fragmentation: Line 144 in c1779c1
Parsing As for Another open question is what to do with other UNIX platforms. Is the reserved block something which exists in Linux only? If not how can we determine its value on other UNIX platforms (aka is |
Maybe I am doing my math wrong but is this not why it's not taking them into account? I'm not normally a Python developer, but this seems to make sense. In the pstuil code you currently have: From the Python docs for 2.7.11 here I see that Now I am not sure how reliable the As a side note, I would think you could use the two values to find the value of the actual space reserved too without having to add anything to pusitls. |
Yes, you are right: |
|
Awesome this looks great, thanks for acting on this so quickly! I'm glad it wasn't as complicated as originally thought! |
Yeah I'm glad too. It's not complicated because you have all the necessary pieces already in place but the math to calculate useful metrics out of those pieces is kinda hard to get right (it took me all day), suggesting a wrapper on top of |
Thank you for fixing this! |
* origin/master: (121 commits) update HISTORY/README giampaolo#810: rename windows wheels to make pip 7.1.2 happy add doc warning about disk_io_counter() numbers which may overlap (se giampaolo#802) update HISTORY git travis/osx error fix typo fix travis err add STAT for ps.py Convert string arguments to bytes appveyor download script: check the num of download files and print a warning if it's < than expected win / CI: try not to upgrade pip version and see whether pip produces compatible wheels refactor makefile makefile refactoring makefile refactoring Updated to use better if/else/endif values (my bad) Updated HISTORY to explain better that Win XP still uses 32bit values Reverted test code, will add in a different PR Styling fixes (spaces instead of tabs) PEP 8 compliance and history update (Vista+ only for fix) Type fix Continue on RuntimeError when running df on partitions it can't run on Fix disk_usage test to use 1 kB block size due to issues with OS X Add comment lines to ifs for win versions Actually does need it in XP/2000 unfortunately Tried to keep the mingw32 support but win 7 sdk is causing issues Whoops, whitespace issue Add back in ws2tcpip.h in the proper place in Win XP / Win 2000 Fixes for compiling on Win XP/Win 200 Update HISTORY.rst with giampaolo#816 issue bug fix Fix for windows net_io_counters wrapping after 4.3GB due to MIB_IFROW using DWORD. Updated to use MIB_IF_ROW2 which gives ULONG values instead. This causes more breaking changes for Windows XP and all Windows versions less than Vista / Server 2008 meaning that it should have no problems working on Vista / Server 2008 and beyond. fix doc indentation doc indentation fix giampaolo#829: disk_usage().percent takes reserved root space into account giampaolo#829: add tests to compare disk_usage() with 'df' cmdline utility small refactoring update comment update badges move stuff around reorganize (move stuff in) _common.py def __all__ for _common.py module reorganize (move) test utils update __all__ small @memoize refactoring Fix psutil.virtual_memory() type mismatch for NetBSD. prettyfy code prettyfy code update README Sets Makefile variable for imports compatible with Python 3.x fix linux test memory_maps: use bytes fir unpackment err refactor smaps code linux memory_maps refactoring fix typo update doc update version and HISTORY re-enable win services re-enable all tests on windows try to upgrade pip try to upgrade pip try to upgrade pip try to install pip globally try to upgrade pip force build of old 4.1.0 ver giampaolo#817: add script to download exes/whels from appveyor appveyor exp 5 appveyor exp 4 appveyor exp 3 appveyor exp 2 appveyor/ci#806 (comment) appveyor exp appveyor/ci#806 (comment) appveyor experiment appveyor experiment appveyor: attempt differe VS config for py 3.5 fix typo restore previous appveyor conf + try to add python 3.5 64 bits try easier appveyor conf, see pypa/packaging.python.org#172 try to make appveyor create exes/wheels add freebsd dev notes refactor ctx switches uids/gids refactoring refactor num_threads more refactoring [Linux] Process.name() is 25% faster (on python 3) ignore me remove outdated test [Linux] speedup Process.status() by 28% [Linux] speedup Process.pid() by 20% by reading it from /proc/pid/stat instead of /proc/pid/status set ppid linux set ppid fix 813: have as_dict() ignore extraneous attribute names which getsattached to the Process instance pep8 fixes fix giampaolo#812: [NetBSD] fix compilation on NetBSD-5.x. build fix: MNT_RELATIME and MNT_EXTATTR are not available on NetBSD-5 build fix: declare warn() update IDEAS fix win tests better AD error handling on win service descr: handle unicode errors service descr: handle empty description str check PyUnicodeDecode return value add services memory leak tests update doc ...
Hi!
As described here: NagiosEnterprises/ncpa#102 the disk usage differs between df command and psutil output.
Is there an explanation about this?
The text was updated successfully, but these errors were encountered: