complicated!
* forking for df takes time!
+.. note:: if decide to deprecate df_wrapper, can change FilesystemFillState to
+ have full mount point info -> remove NOT_REAL_FILESYSTEMS_SPEC
+
.. codeauthor:: Intra2net
"""
IGNORE_MOUNT_TYPES = 'cgroup', 'pstore'
#: proper filesystems that usually correspond to data on the disc
-#: (as opposed to tmpfs, rootfs, sysfs, ...)
-REAL_FILESYSTEMS = 'ext2', 'ext3', 'ext4', 'zfs', 'btrs', 'reiserfs', 'nfs4'
-
+#: (value for field MountPoint.vfstype)
+REAL_FILESYSTEMS_TYPE = 'ext2', 'ext3', 'ext4', 'zfs', 'btrs', 'reiserfs', \
+ 'nfs4'
+
+#: filesystem name (MountPoint.spec / FilesystemFillState.name) that usually
+#: does not correspond to something on disc (except, maybe, swap)
+#: (only still here because df does not give fs type result, so class
+#: FilesystemFillState does not have full mount info)
+NOT_REAL_FILESYSTEMS_SPEC = 'none', 'shmfs', 'procfs', 'tmpfs', 'ramfs', \
+ 'proc', 'rootfs', 'sysfs', 'devpts', 'sunrpc', \
+ 'nfsd'
class FilesystemFillState:
""" representation of 1 line of the 'df' command
warn('multiple non-rootfs mounts in same file {0}!'
.format(new_mount.file))
if new_mount.spec in specs \
- and new_mount.spec in REAL_FILESYSTEMS:
+ and new_mount.vfstype in REAL_FILESYSTEMS_TYPE:
continue # e.g. bind mounts; ignore this mount
# if we reach this, this is no duplicate; remember it
from buffers import LogarithmicBuffer
from file_helpers import get_filesystem_fill_states, FilesystemFillState, \
get_mount_info, get_fill_from_statvfs, \
- REAL_FILESYSTEMS, size_str
+ NOT_REAL_FILESYSTEMS_SPEC, size_str
from iter_helpers import pairwise
internal helper called from __init__ and run
"""
- if fs_state.name not in REAL_FILESYSTEMS:
+ if fs_state.name in NOT_REAL_FILESYSTEMS_SPEC:
return []
if fs_state.size == 0:
return []
def get_states():
if mounts is None:
for state in get_filesystem_fill_states():
- if state.name not in REAL_FILESYSTEMS:
+ if state.name in NOT_REAL_FILESYSTEMS_SPEC:
continue
yield state
else: