KeyError: 'syscalls' and terminal layout broken with Glances 3.2.4+ #1956

This commit is contained in:
nicolargo 2021-11-22 11:41:11 +01:00
parent 6bf417bab5
commit 7b9fcc53d6
2 changed files with 16 additions and 4 deletions

View File

@ -81,6 +81,11 @@ another while ensuring that the tasks do not conflict.',
'rate': True, 'rate': True,
'min_symbol': 'K', 'min_symbol': 'K',
'short_name': 'sw_int'}, '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.', 'cpucore': {'description': 'Total number of CPU core.',
'unit': 'number'}, 'unit': 'number'},
'time_since_update': {'description': 'Number of seconds since last update.', 'time_since_update': {'description': 'Number of seconds since last update.',

View File

@ -1005,27 +1005,34 @@ class GlancesPlugin(object):
return [] return []
# Check if a shortname is defined # 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'] key_name = self.fields_description[key]['short_name']
else: else:
key_name = key key_name = key
# Check if unit is defined and get the short unit char in the unit_sort dict # 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 # Get the shortname
unit_short = fields_unit_short[self.fields_description[key]['unit']] unit_short = fields_unit_short[self.fields_description[key]['unit']]
else: else:
unit_short = '' unit_short = ''
# Check if unit is defined and get the unit type unit_type dict # 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 # Get the shortname
unit_type = fields_unit_type[self.fields_description[key]['unit']] unit_type = fields_unit_type[self.fields_description[key]['unit']]
else: else:
unit_type = 'float' unit_type = 'float'
# Is it a rate ? Yes, compute it thanks to the time_since_update key # 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'] value = self.stats[key] // self.stats['time_since_update']
else: else:
value = self.stats[key] value = self.stats[key]