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

[WIP] psutil.disk_swaps() (swap partitions) #1694

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Conversation

giampaolo
Copy link
Owner

@giampaolo giampaolo commented Feb 14, 2020

This implements #1681, by adding a new psutil.disk_swaps() which lists swap partitions (and swap files).

# Linux
>>> import psutil
>>> psutil.disk_swaps()
[sdiskswaps(path='/dev/nvme0n1p3', total=11718652, used=2724, fstype='partition', priority=-2)]
# Windows
>>> import psutil
>>> psutil.disk_swaps()
[sdiskswaps(path='C:\\pagefile.sys', total=1118652, used=5721, peak=3453)]

Linux and Windows only for now, but at least macOS and/or FreeBSD would also be nice to have.
I'm still not 100% sure about the name.

UPDATE - added support for:

  • Linux
  • Windows
  • FreeBSD
  • OpenBSD

@giampaolo
Copy link
Owner Author

giampaolo commented Feb 14, 2020

And here's some bikeshedding.
Current name:

  • disk_swaps()
    • +1 because it's neutral about swap partitions vs. swap files (Linux can have both, Windows only has files (called pagefiles))
    • +1 /proc/swaps suggests someone already did the bikeshedding =)

Other possible names:

  • swap_partitions():
    • +1 because of the swap prefix
    • -1 because we can also list swap files
  • swap_disks():
    • +1 because we already have the "swap_" prefix of swap_memory()
    • -1 because it sounds like entries refer to an entire disk
  • swap_locations():
    • +1 (reuse "swap_" prefix)

Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant