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
32
bpytop.py
32
bpytop.py
|
@ -2990,6 +2990,8 @@ class MemCollector(Collector):
|
||||||
|
|
||||||
old_disks: List[str] = []
|
old_disks: List[str] = []
|
||||||
|
|
||||||
|
fstab_filter: List[str] = []
|
||||||
|
|
||||||
excludes: List[str] = ["squashfs", "nullfs"]
|
excludes: List[str] = ["squashfs", "nullfs"]
|
||||||
if SYSTEM == "BSD": excludes += ["devfs", "tmpfs", "procfs", "linprocfs", "gvfs", "fusefs"]
|
if SYSTEM == "BSD": excludes += ["devfs", "tmpfs", "procfs", "linprocfs", "gvfs", "fusefs"]
|
||||||
|
|
||||||
|
@ -3054,7 +3056,6 @@ class MemCollector(Collector):
|
||||||
io_string: str
|
io_string: str
|
||||||
u_percent: int
|
u_percent: int
|
||||||
disk_list: List[str] = []
|
disk_list: List[str] = []
|
||||||
fstab_filter: List[str] = []
|
|
||||||
cls.disks = {}
|
cls.disks = {}
|
||||||
|
|
||||||
if CONFIG.disks_filter:
|
if CONFIG.disks_filter:
|
||||||
|
@ -3074,21 +3075,28 @@ class MemCollector(Collector):
|
||||||
errlog.error(f'Caused by outdated psutil version.')
|
errlog.error(f'Caused by outdated psutil version.')
|
||||||
errlog.exception(f'{e}')
|
errlog.exception(f'{e}')
|
||||||
io_counters = None
|
io_counters = None
|
||||||
try:
|
|
||||||
with open('/etc/fstab','r') as fstab:
|
if CONFIG.use_fstab and not cls.fstab_filter:
|
||||||
for line in fstab:
|
try:
|
||||||
line = line.strip()
|
with open('/etc/fstab','r') as fstab:
|
||||||
if line and not line.startswith('#'):
|
for line in fstab:
|
||||||
mount_data = (line.split())
|
line = line.strip()
|
||||||
if mount_data[2].lower() != "swap":
|
if line and not line.startswith('#'):
|
||||||
fstab_filter += [mount_data[1]]
|
mount_data = (line.split())
|
||||||
except IOError:
|
if mount_data[2].lower() != "swap":
|
||||||
pass
|
cls.fstab_filter += [mount_data[1]]
|
||||||
|
errlog.debug(f'new fstab_filter set : {cls.fstab_filter}')
|
||||||
|
except IOError:
|
||||||
|
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):
|
for disk in psutil.disk_partitions(CONFIG.use_fstab):
|
||||||
disk_io = None
|
disk_io = None
|
||||||
io_string = ""
|
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
|
continue
|
||||||
disk_name = disk.mountpoint.rsplit('/', 1)[-1] if not disk.mountpoint == "/" else "root"
|
disk_name = disk.mountpoint.rsplit('/', 1)[-1] if not disk.mountpoint == "/" else "root"
|
||||||
#while disk_name in disk_list: disk_name += "_"
|
#while disk_name in disk_list: disk_name += "_"
|
||||||
|
|
Loading…
Reference in New Issue