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]