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

Provide function to get system disk partitions #174

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

Provide function to get system disk partitions #174

giampaolo opened this issue May 23, 2014 · 8 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on June 15, 2011 11:07:41

In issue 172 we added psutil.disk_usage() function which provides disk usage 
statistics starting from a given path.
What's missing is a facility to get all system partitions (mount points) to be 
used in conjunction with psutil.disk_usage() which would provide all the pieces 
to perform a complete monitoring of all disks instealled on the system.

What I have in mind:

>>> psutil.disk_partitions()
[partition(device='/dev/sda3', mountpoint='/', fstype='ext4')
partition(device='/dev/sda7', mountpoint='/home', fstype='ext4')
partition(device='/dev/sdb1', mountpoint='/media/1CA0-065B', fstype='vfat')
partition(device='/dev/sda6', mountpoint='/media/Dati', fstype='fuseblk')]

The way I see it, disk_partitions() should return information about *mounted* 
physical devices only, and hence behave more like "df" rather than "fdisk -l".
Also, "df" reports mount points which doesn't refer to actual physical devices, 
such as "/dev/shm" ( 
http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html ), 
"/var/run" and "/var/lock". 
IMO, we should ignore them.

Attached is a draft for Linux.
Still have to look into other implementations.

Attachment: linux.py

Original issue: http://code.google.com/p/psutil/issues/detail?id=174

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on June 15, 2011 03:00:37

Implemented on Linux in r1026 .
I provided an "all" optional argument defaulting to False to filter for 
physical devices only.


>>> psutil.disk_partitions()
partition(device='/dev/sda3', mountpoint='/', fstype='ext4')
partition(device='/dev/sda7', mountpoint='/home', fstype='ext4')
partition(device='/dev/sdb1', mountpoint='/media/1CA0-065B', fstype='vfat')
partition(device='/dev/sda6', mountpoint='/media/Dati', fstype='fuseblk')
>>>


>>> psutil.disk_partitions(all=True)
partition(device='/dev/sda3', mountpoint='/', fstype='ext4')
partition(device='proc', mountpoint='/proc', fstype='proc')
partition(device='', mountpoint='/sys', fstype='sysfs')
partition(device='fusectl', mountpoint='/sys/fs/fuse/connections', 
fstype='fusectl')
partition(device='', mountpoint='/sys/kernel/debug', fstype='debugfs')
partition(device='', mountpoint='/sys/kernel/security', fstype='securityfs')
partition(device='', mountpoint='/dev', fstype='devtmpfs')
partition(device='', mountpoint='/dev/pts', fstype='devpts')
partition(device='', mountpoint='/dev/shm', fstype='tmpfs')
partition(device='', mountpoint='/var/run', fstype='tmpfs')
partition(device='', mountpoint='/var/lock', fstype='tmpfs')
partition(device='/dev/sda7', mountpoint='/home', fstype='ext4')
partition(device='binfmt_misc', mountpoint='/proc/sys/fs/binfmt_misc', 
fstype='binfmt_misc')
partition(device='gvfs-fuse-daemon', mountpoint='/home/giampaolo/.gvfs', 
fstype='fuse.gvfs-fuse-daemon')
partition(device='/dev/sdb1', mountpoint='/media/1CA0-065B', fstype='vfat')
partition(device='/dev/sda6', mountpoint='/media/Dati', fstype='fuseblk')

Status: Started
Labels: Milestone-0.2.2 Progress-1in4

@giampaolo
Copy link
Owner Author

From g.rodola on June 16, 2011 03:07:01

FreeBSD implementation added as r1027 .

Labels: -Progress-1in4 Progress-2in4

@giampaolo
Copy link
Owner Author

From g.rodola on June 17, 2011 11:04:03

Implemented on Windows in r1030 .

Labels: -Progress-2in4 Progress-3in4

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:46:15

Attached is a patch for OS X support.  It is identical to BSD support but I 
couldn't find a good way to share code between the BSD and OS X 
implementations.  That being said, I copied the approach for BSD to implement 
OS X support.  If you know a better way to do this so that OS X uses the BSD 
sources for this, since OS X is a BSD derivative, feel free to just commit your version.

Attachment: issue_174_os_x.patch

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 09:56:28

Added in r1047 .
As for now I can't think of a smart way to share the same code between OSX and 
FreeBSD. I'll think about it later. Closing out as FixedInSvn for now.

Status: FixedInSVN
Labels: -Progress-3in4 Progress-4in4

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 10:52:41

Labels: Milestone-0.3.0

@giampaolo
Copy link
Owner Author

From g.rodola on July 08, 2011 12:07:35

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:01:08

Updated csets after the SVN -> Mercurial migration: r1026 == revision 
5e77d0b5125a r1027 == revision d05c75bf4288 r1030 == revision a566c8a5fbf6 
r1047 == revision 186496a8bd0f

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

1 participant