From f354d1a2b6b925036d9735aac29cbcfe3e5aa06d Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 5 Jun 2021 09:06:10 +0200 Subject: [PATCH] Correct issue with bad key for AMPS --- conf/glances.conf | 8 ++++++-- docs/gw/influxdb.rst | 15 ++++++++++----- docs/man/glances.1 | 2 +- glances/__init__.py | 2 +- glances/outputs/glances_stdout_issue.py | 16 ++++++++++------ glances/plugins/glances_amps.py | 6 +++++- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/conf/glances.conf b/conf/glances.conf index f93225ef..da9f62a4 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -10,8 +10,8 @@ refresh=2 # Does Glances should check if a newer version is available on PyPI ? check_update=false # History size (maximum number of values) -# Default is 28800: 1 day with 1 point every 3 seconds -history_size=28800 +# Default is 3600 seconds (1 hour) +history_size=3600 ############################################################################## # User interface @@ -388,6 +388,10 @@ max_name_size=20 # Set the following key to True to display all containers all=False +[amps] +# AMPs configuration are defined in the bottom of this file +disable=False + ############################################################################## # Client/server ############################################################################## diff --git a/docs/gw/influxdb.rst b/docs/gw/influxdb.rst index c431d8f5..e46492e7 100644 --- a/docs/gw/influxdb.rst +++ b/docs/gw/influxdb.rst @@ -5,7 +5,7 @@ InfluxDB You can export statistics to an ``InfluxDB`` server (time series server). -In Glances version 3.1.8 and higher, the way Glances exports stats to +In Glances version 3.2.0 and higher, the way Glances exports stats to InfluxDB changes. The following fields will be added as tags: - key stats (for example *interface_name* for network, container *name* for docker...) @@ -21,10 +21,15 @@ Glances InfluxDB data model: | | system | | | | iowait... | | +---------------+-----------------------+-----------------------+ -| network | rx | | -| | tx | | -| | time_since_update... | hostname | -|  | | interface_name | +| network | read_bytes | hostname | +| | write_bytes | disk_name | +| | time_since_update... | | +|  | | | ++---------------+-----------------------+-----------------------+ +| diskio | rx | hostname | +| | tx | interface_name | +| | time_since_update... | | +|  | | | +---------------+-----------------------+-----------------------+ | docker | cpu_percent | hostname | | | memory_usage... | name | diff --git a/docs/man/glances.1 b/docs/man/glances.1 index 9f341163..fac8f6ab 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLANCES" "1" "May 29, 2021" "3.1.8b9" "Glances" +.TH "GLANCES" "1" "Jun 05, 2021" "3.2.0b0" "Glances" .SH NAME glances \- An eye on your system . diff --git a/glances/__init__.py b/glances/__init__.py index 1a18b51b..b6ba893b 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -29,7 +29,7 @@ import sys # Global name # Version should start and end with a numerical char # See https://packaging.python.org/specifications/core-metadata/#version -__version__ = '3.1.8b9' +__version__ = '3.2.0b0' __author__ = 'Nicolas Hennion ' __license__ = 'LGPLv3' diff --git a/glances/outputs/glances_stdout_issue.py b/glances/outputs/glances_stdout_issue.py index ffdf7c3c..9e363c5a 100644 --- a/glances/outputs/glances_stdout_issue.py +++ b/glances/outputs/glances_stdout_issue.py @@ -65,7 +65,7 @@ class GlancesStdoutIssue(object): def print_version(self): msg = 'Glances version {} with PsUtil {}'.format( - colors.BLUE + __version__ + colors.NO, + colors.BLUE + __version__ + colors.NO, colors.BLUE + psutil_version + colors.NO) sys.stdout.write('='*len(msg) + '\n') sys.stdout.write(msg) @@ -89,7 +89,7 @@ class GlancesStdoutIssue(object): if stats._plugins[plugin].is_disable(): # If current plugin is disable # then continue to next plugin - result = colors.ORANGE + '[N/A]'.rjust(19 - len(plugin)) + result = colors.NO + '[N/A]'.rjust(19 - len(plugin)) message = colors.NO self.print_issue(plugin, result, message) continue @@ -109,14 +109,18 @@ class GlancesStdoutIssue(object): result = (colors.GREEN + '[OK] ' + colors.BLUE + - ' {:.4f}s '.format(counter.get())).rjust(40 - len(plugin)) - message = colors.NO + str(stat)[0:TERMINAL_WIDTH-40] + ' {:.5f}s '.format(counter.get())).rjust(41 - len(plugin)) + if isinstance(stat, list) and len(stat) > 0 and 'key' in stat[0]: + key = 'key={} '.format(stat[0]['key']) + message = colors.ORANGE + key + colors.NO + str(stat)[0:TERMINAL_WIDTH-41-len(key)] + else: + message = colors.NO + str(stat)[0:TERMINAL_WIDTH-41] else: result = (colors.RED + '[ERROR]' + colors.BLUE + - ' {:.4f}s '.format(counter.get())).rjust(40 - len(plugin)) - message = colors.NO + str(stat_error)[0:TERMINAL_WIDTH-40] + ' {:.5f}s '.format(counter.get())).rjust(41 - len(plugin)) + message = colors.NO + str(stat_error)[0:TERMINAL_WIDTH-41] self.print_issue(plugin, result, message) # Return True to exit directly (no refresh) diff --git a/glances/plugins/glances_amps.py b/glances/plugins/glances_amps.py index 4b4c0fa4..ff719297 100644 --- a/glances/plugins/glances_amps.py +++ b/glances/plugins/glances_amps.py @@ -41,6 +41,10 @@ class Plugin(GlancesPlugin): # Init the list of AMP (classe define in the glances/amps_list.py script) self.glances_amps = glancesAmpsList(self.args, self.config) + def get_key(self): + """Return the key of the list.""" + return 'name' + @GlancesPlugin._check_decorator @GlancesPlugin._log_result_decorator def update(self): @@ -50,7 +54,7 @@ class Plugin(GlancesPlugin): if self.input_method == 'local': for k, v in iteritems(self.glances_amps.update()): - stats.append({'key': k, + stats.append({'key': self.get_key(), 'name': v.NAME, 'result': v.result(), 'refresh': v.refresh(), -- GitLab