mirror of https://github.com/aristocratos/bpytop
use_fstab optimizations.
Better handling of non-exiting /etc/fstab filter status debug loggingpull/230/head
parent
1c0bc41c36
commit
6fd08c8361
16
bpytop.py
16
bpytop.py
|
@ -2990,6 +2990,8 @@ class MemCollector(Collector):
|
|||
|
||||
old_disks: List[str] = []
|
||||
|
||||
fstab_filter: List[str] = []
|
||||
|
||||
excludes: List[str] = ["squashfs", "nullfs"]
|
||||
if SYSTEM == "BSD": excludes += ["devfs", "tmpfs", "procfs", "linprocfs", "gvfs", "fusefs"]
|
||||
|
||||
|
@ -3054,7 +3056,6 @@ class MemCollector(Collector):
|
|||
io_string: str
|
||||
u_percent: int
|
||||
disk_list: List[str] = []
|
||||
fstab_filter: List[str] = []
|
||||
cls.disks = {}
|
||||
|
||||
if CONFIG.disks_filter:
|
||||
|
@ -3074,6 +3075,8 @@ class MemCollector(Collector):
|
|||
errlog.error(f'Caused by outdated psutil version.')
|
||||
errlog.exception(f'{e}')
|
||||
io_counters = None
|
||||
|
||||
if CONFIG.use_fstab and not cls.fstab_filter:
|
||||
try:
|
||||
with open('/etc/fstab','r') as fstab:
|
||||
for line in fstab:
|
||||
|
@ -3081,14 +3084,19 @@ class MemCollector(Collector):
|
|||
if line and not line.startswith('#'):
|
||||
mount_data = (line.split())
|
||||
if mount_data[2].lower() != "swap":
|
||||
fstab_filter += [mount_data[1]]
|
||||
cls.fstab_filter += [mount_data[1]]
|
||||
errlog.debug(f'new fstab_filter set : {cls.fstab_filter}')
|
||||
except IOError:
|
||||
pass
|
||||
CONFIG.use_fstab = False
|
||||
errlog.debug(f'Error reading fstab, use_fstab flag reset to {CONFIG.use_fstab}')
|
||||
if not CONFIG.use_fstab and cls.fstab_filter:
|
||||
cls.fstab_filter = []
|
||||
errlog.debug(f'use_fstab flag has been turned to {CONFIG.use_fstab}, fstab_filter cleared')
|
||||
|
||||
for disk in psutil.disk_partitions(CONFIG.use_fstab):
|
||||
disk_io = None
|
||||
io_string = ""
|
||||
if CONFIG.use_fstab and disk.mountpoint not in fstab_filter:
|
||||
if CONFIG.use_fstab and disk.mountpoint not in cls.fstab_filter:
|
||||
continue
|
||||
disk_name = disk.mountpoint.rsplit('/', 1)[-1] if not disk.mountpoint == "/" else "root"
|
||||
#while disk_name in disk_list: disk_name += "_"
|
||||
|
|
Loading…
Reference in New Issue