mirror of https://github.com/aristocratos/bpytop
Added exception catch for psutil io_counters error caused by psutil < 5.7.0 and Linux kernel >= 5
parent
fd8852a160
commit
d4b101c2d1
15
bpytop.py
15
bpytop.py
|
@ -2498,6 +2498,8 @@ class MemCollector(Collector):
|
||||||
disk_hist: Dict[str, Tuple] = {}
|
disk_hist: Dict[str, Tuple] = {}
|
||||||
timestamp: float = time()
|
timestamp: float = time()
|
||||||
|
|
||||||
|
io_error: bool = False
|
||||||
|
|
||||||
old_disks: List[str] = []
|
old_disks: List[str] = []
|
||||||
|
|
||||||
excludes: List[str] = ["squashfs"]
|
excludes: List[str] = ["squashfs"]
|
||||||
|
@ -2573,7 +2575,16 @@ class MemCollector(Collector):
|
||||||
else:
|
else:
|
||||||
filtering = tuple(v.strip() for v in CONFIG.disks_filter.strip().split(","))
|
filtering = tuple(v.strip() for v in CONFIG.disks_filter.strip().split(","))
|
||||||
|
|
||||||
|
try:
|
||||||
io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
|
io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
|
||||||
|
except ValueError as e:
|
||||||
|
if not cls.io_error:
|
||||||
|
cls.io_error = True
|
||||||
|
errlog.error(f'Non fatal error during disk io collection!')
|
||||||
|
if psutil.version_info[0] < 5 or (psutil.version_info[0] == 5 and psutil.version_info[1] < 7):
|
||||||
|
errlog.error(f'Caused by outdated psutil version.')
|
||||||
|
errlog.exception(f'{e}')
|
||||||
|
io_counters = None
|
||||||
|
|
||||||
for disk in psutil.disk_partitions():
|
for disk in psutil.disk_partitions():
|
||||||
disk_io = None
|
disk_io = None
|
||||||
|
@ -2602,6 +2613,7 @@ class MemCollector(Collector):
|
||||||
cls.disks[disk.device][name] = floating_humanizer(getattr(disk_u, name, 0))
|
cls.disks[disk.device][name] = floating_humanizer(getattr(disk_u, name, 0))
|
||||||
|
|
||||||
#* Collect disk io
|
#* Collect disk io
|
||||||
|
if io_counters:
|
||||||
try:
|
try:
|
||||||
if SYSTEM == "Linux":
|
if SYSTEM == "Linux":
|
||||||
dev_name = os.path.realpath(disk.device).rsplit('/', 1)[-1]
|
dev_name = os.path.realpath(disk.device).rsplit('/', 1)[-1]
|
||||||
|
@ -2618,7 +2630,8 @@ class MemCollector(Collector):
|
||||||
disk_read = round((disk_io.read_bytes - cls.disk_hist[disk.device][0]) / (time() - cls.timestamp))
|
disk_read = round((disk_io.read_bytes - cls.disk_hist[disk.device][0]) / (time() - cls.timestamp))
|
||||||
disk_write = round((disk_io.write_bytes - cls.disk_hist[disk.device][1]) / (time() - cls.timestamp))
|
disk_write = round((disk_io.write_bytes - cls.disk_hist[disk.device][1]) / (time() - cls.timestamp))
|
||||||
except:
|
except:
|
||||||
pass
|
disk_read = disk_write = 0
|
||||||
|
else:
|
||||||
disk_read = disk_write = 0
|
disk_read = disk_write = 0
|
||||||
|
|
||||||
if disk_io:
|
if disk_io:
|
||||||
|
|
Loading…
Reference in New Issue