diff --git a/NEWS b/NEWS index a5411f51..4c9a4cc7 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ Enhancements and new features: * Add time zone to the current time #1249 * Use https URLs for checking external IP #1253 * Add labels support to Promotheus exporter #1255 + * Overlap in Web UI when monitoring a machine with 16 cpu threads #1265 One more thing ! A new Grafana Dash is available with: * Network interface variable diff --git a/glances/plugins/glances_percpu.py b/glances/plugins/glances_percpu.py index 5b69e02d..033b9735 100644 --- a/glances/plugins/glances_percpu.py +++ b/glances/plugins/glances_percpu.py @@ -19,6 +19,7 @@ """Per-CPU plugin.""" +from glances.logger import logger from glances.cpu_percent import cpu_percent from glances.plugins.glances_plugin import GlancesPlugin @@ -76,6 +77,10 @@ class Plugin(GlancesPlugin): # Init the return message ret = [] + # Only process if stats exist... + if not self.stats or self.is_disable(): + return ret + # No per CPU stat ? Exit... if not self.stats: msg = 'PER CPU not available' @@ -83,35 +88,36 @@ class Plugin(GlancesPlugin): return ret # Build the string message - # Header - msg = '{:8}'.format('PER CPU') - ret.append(self.curse_add_line(msg, "TITLE")) + if self.is_disable('quicklook'): + msg = '{:7}'.format('PER CPU') + ret.append(self.curse_add_line(msg, "TITLE")) - # Total per-CPU usage - for cpu in self.stats: - try: - msg = '{:6.1f}%'.format(cpu['total']) - except TypeError: - # TypeError: string indices must be integers (issue #1027) - msg = '{:>6}%'.format('?') - ret.append(self.curse_add_line(msg)) - - # Stats per-CPU + # Per CPU stats displayed per line for stat in ['user', 'system', 'idle', 'iowait', 'steal']: if stat not in self.stats[0]: continue - - ret.append(self.curse_new_line()) - msg = '{:8}'.format(stat + ':') + msg = '{:>7}'.format(stat) ret.append(self.curse_add_line(msg)) - for cpu in self.stats: + + # Per CPU stats displayed per column + for cpu in self.stats: + ret.append(self.curse_new_line()) + if self.is_disable('quicklook'): try: - msg = '{:6.1f}%'.format(cpu[stat]) + msg = '{:6.1f}%'.format(cpu['total']) except TypeError: # TypeError: string indices must be integers (issue #1027) msg = '{:>6}%'.format('?') + ret.append(self.curse_add_line(msg)) + for stat in ['user', 'system', 'idle', 'iowait', 'steal']: + if stat not in self.stats[0]: + continue + try: + msg = '{:6.1f}%'.format(cpu[stat]) + except TypeError: + msg = '{:>6}%'.format('?') ret.append(self.curse_add_line(msg, - self.get_alert(cpu[stat], header=stat))) + self.get_alert(cpu[stat], + header=stat))) - # Return the message with decoration return ret diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 83458e1d..c9e315e5 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -124,18 +124,20 @@ class GlancesPlugin(object): """Return the key of the list.""" return None - def is_enable(self): + def is_enable(self, plugin_name=None): """Return true if plugin is enabled.""" + if not plugin_name: + plugin_name = self.plugin_name try: - d = getattr(self.args, 'disable_' + self.plugin_name) + d = getattr(self.args, 'disable_' + plugin_name) except AttributeError: return True else: return d is False - def is_disable(self): + def is_disable(self, plugin_name=None): """Return true if plugin is disabled.""" - return not self.is_enable() + return not self.is_enable(plugin_name=plugin_name) def _json_dumps(self, d): """Return the object 'd' in a JSON format.