diff options
author | nicolargo <nicolas@nicolargo.com> | 2021-11-22 11:41:11 +0100 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2021-11-22 11:41:11 +0100 |
commit | 7b9fcc53d65549bf0809ea5cf736ed09b21825e9 (patch) | |
tree | 67abfd91af8a6890dae641a5bcf6bc2e018ba793 | |
parent | 6bf417bab542eeefe49523d2ff0f926005d93115 (diff) |
KeyError: 'syscalls' and terminal layout broken with Glances 3.2.4+ #1956
-rw-r--r-- | glances/plugins/glances_cpu.py | 5 | ||||
-rw-r--r-- | glances/plugins/glances_plugin.py | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/glances/plugins/glances_cpu.py b/glances/plugins/glances_cpu.py index f8412d95..fe66ccb7 100644 --- a/glances/plugins/glances_cpu.py +++ b/glances/plugins/glances_cpu.py @@ -81,6 +81,11 @@ another while ensuring that the tasks do not conflict.', 'rate': True, 'min_symbol': 'K', 'short_name': 'sw_int'}, + 'syscalls': {'description': 'number of system calls per second. Always 0 on Linux OS.', + 'unit': 'number', + 'rate': True, + 'min_symbol': 'K', + 'short_name': 'sw_int'}, 'cpucore': {'description': 'Total number of CPU core.', 'unit': 'number'}, 'time_since_update': {'description': 'Number of seconds since last update.', diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 24981c6e..a24a906c 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -1005,27 +1005,34 @@ class GlancesPlugin(object): return [] # Check if a shortname is defined - if 'short_name' in self.fields_description[key]: + if key in self.fields_description and \ + 'short_name' in self.fields_description[key]: key_name = self.fields_description[key]['short_name'] else: key_name = key # Check if unit is defined and get the short unit char in the unit_sort dict - if 'unit' in self.fields_description[key] and self.fields_description[key]['unit'] in fields_unit_short: + if key in self.fields_description and \ + 'unit' in self.fields_description[key] and \ + self.fields_description[key]['unit'] in fields_unit_short: # Get the shortname unit_short = fields_unit_short[self.fields_description[key]['unit']] else: unit_short = '' # Check if unit is defined and get the unit type unit_type dict - if 'unit' in self.fields_description[key] and self.fields_description[key]['unit'] in fields_unit_type: + if key in self.fields_description and \ + 'unit' in self.fields_description[key] and \ + self.fields_description[key]['unit'] in fields_unit_type: # Get the shortname unit_type = fields_unit_type[self.fields_description[key]['unit']] else: unit_type = 'float' # Is it a rate ? Yes, compute it thanks to the time_since_update key - if 'rate' in self.fields_description[key] and self.fields_description[key]['rate'] is True: + if key in self.fields_description and \ + 'rate' in self.fields_description[key] and \ + self.fields_description[key]['rate'] is True: value = self.stats[key] // self.stats['time_since_update'] else: value = self.stats[key] |