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

pull/1961/head
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,
'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.',

View File

@ -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]