diff options
author | nicolargo <nicolashennion@gmail.com> | 2020-02-27 14:59:52 +0100 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2020-02-27 14:59:52 +0100 |
commit | 1e8bf7bd5fdec1d2b8eb85e57a38096466f1b5d9 (patch) | |
tree | 80d8b9f14bcb0987c0189724ca09e61a4a9f6df3 | |
parent | 4369cd76622795397327e4bbc58eeb531aa685bb (diff) |
Glances don't want to run on Crostini (LXC Container, Debian 10, python 3.7.3) #1600
-rw-r--r-- | glances/processes.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/glances/processes.py b/glances/processes.py index 29024bf5..f1291d59 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -64,6 +64,28 @@ class GlancesProcesses(object): # Extended stats for top process is enable by default self.disable_extended_tag = False + # Test if the system can grab io_counters + try: + p = psutil.Process() + p.io_counters() + except Exception as e: + logger.warning('PsUtil can not grab processes io_counters ({})'.format(e)) + self.disable_io_counters = True + else: + logger.debug('PsUtil can grab processes io_counters') + self.disable_io_counters = False + + # Test if the system can grab gids + try: + p = psutil.Process() + p.gids() + except Exception as e: + logger.warning('PsUtil can not grab processes gids ({})'.format(e)) + self.disable_gids = True + else: + logger.debug('PsUtil can grab processes gids') + self.disable_gids = False + # Maximum number of processes showed in the UI (None if no limit) self._max_processes = None @@ -237,11 +259,9 @@ class GlancesProcesses(object): standard_attrs = ['cmdline', 'cpu_percent', 'cpu_times', 'memory_info', 'memory_percent', 'name', 'nice', 'pid', 'ppid', 'status', 'username', 'status', 'num_threads'] - # io_counters availability: Linux, BSD, Windows, AIX - if not MACOS and not SUNOS and not WSL: + if not self.disable_io_counters: standard_attrs += ['io_counters'] - # gids availability: Unix - if not WINDOWS: + if not self.disable_gids: standard_attrs += ['gids'] # and build the processes stats list (psutil>=5.3.0) |