From 4969c1906501aa2913ddab1050c8c3fca0277bca Mon Sep 17 00:00:00 2001 From: Bartlomiej Cieszkowski Date: Sun, 9 Feb 2020 20:34:32 +0100 Subject: glances can work in console mode on windows - windows-curses --- glances/main.py | 4 ---- glances/outputs/glances_curses.py | 17 +++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/glances/main.py b/glances/main.py index dad17e6f..a869e3cb 100644 --- a/glances/main.py +++ b/glances/main.py @@ -305,10 +305,6 @@ Examples of use: if args.disable_autodiscover: logger.info("Auto discover mode is disabled") - # By default Windows is started in Web mode - if WINDOWS: - args.webserver = True - # In web server mode if args.webserver: args.process_short_name = True diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 782a1a32..b78c9857 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -31,14 +31,15 @@ from glances.processes import glances_processes from glances.timer import Timer # Import curses library for "normal" operating system -if not WINDOWS: - try: - import curses - import curses.panel - from curses.textpad import Textbox - except ImportError: - logger.critical("Curses module not found. Glances cannot start in standalone mode.") - sys.exit(1) +try: + import curses + import curses.panel + from curses.textpad import Textbox +except ImportError: + logger.critical("Curses module not found. Glances cannot start in standalone mode.") + if WINDOWS: + logger.critical("For Windows you can try installing windows-curses with pip install.") + sys.exit(1) class _GlancesCurses(object): -- cgit v1.2.3 From c66f874e8dfa68407d74c3e0c8c2e89577e52a34 Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:00:34 +0100 Subject: Reduced precision to seconds in influxdb export "To significantly improve compression, use the coarsest precision possible for timestamps." see documentation: https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_reference/#syntax-description --- glances/exports/glances_influxdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glances/exports/glances_influxdb.py b/glances/exports/glances_influxdb.py index 91cfddf3..5df70832 100644 --- a/glances/exports/glances_influxdb.py +++ b/glances/exports/glances_influxdb.py @@ -130,7 +130,7 @@ class Export(GlancesExport): logger.debug("Cannot export empty {} stats to InfluxDB".format(name)) else: try: - self.client.write_points(self._normalize(name, columns, points)) + self.client.write_points(self._normalize(name, columns, points), time_precision="s") except Exception as e: # Log level set to debug instead of error (see: issue #1561) logger.debug("Cannot export {} stats to InfluxDB ({})".format(name, e)) -- cgit v1.2.3 From 84c3549aad855a7d831261df9ab0007c2fe01ff2 Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:08:53 +0100 Subject: Slight glances/README.txt update * Updated link to docs * Added export base class * Added AMPs --- glances/README.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/glances/README.txt b/glances/README.txt index f7ba0575..fdfb2f12 100644 --- a/glances/README.txt +++ b/glances/README.txt @@ -1,7 +1,7 @@ You are in the main Glances source folder. This page is **ONLY** for developers. If you are looking for the user manual, please follow this link: -https://github.com/nicolargo/glances/blob/master/docs/glances-doc.rst +https://glances.readthedocs.io/en/stable/ === @@ -42,6 +42,7 @@ outputs ... exports => Glances export interfaces + glances_export.py "Father class" for exports glances_csv.py The CSV export module glances_influxdb.py The InfluxDB export module glances_mqtt.py The MQTT export module @@ -49,3 +50,9 @@ exports glances_rabbitmq.py The RabbitMQ export module glances_statsd.py The StatsD export module ... +amps + => Glances Application Monitoring Processes (AMP) + glances_amp.py "Father class" for AMPs + glances_default.py Default AMP + glances_nginx.py Nginx AMP + ... -- cgit v1.2.3 From 3190a9fd70a6fe4473f102c63d39c1a1462ec2b8 Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:53:04 +0100 Subject: Update grafana example for diskio Taking into account time_since_update in a similar manner to networks --- conf/glances-grafana.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/glances-grafana.json b/conf/glances-grafana.json index 0156140f..9f5c7c77 100644 --- a/conf/glances-grafana.json +++ b/conf/glances-grafana.json @@ -1243,7 +1243,7 @@ "measurement": "localhost.diskio", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"$disk.read_bytes\") FROM \"localhost.diskio\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"$disk.read_bytes\")/mean(\"$disk.time_since_update\") FROM \"localhost.diskio\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1286,7 +1286,7 @@ "measurement": "localhost.diskio", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"$disk.write_bytes\") FROM \"localhost.diskio\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"$disk.write_bytes\")/mean(\"$disk.time_since_update\") FROM \"localhost.diskio\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -3183,4 +3183,4 @@ "title": "Glances", "uid": "000000002", "version": 10 -} \ No newline at end of file +} -- cgit v1.2.3 From f42ff86f64755a0c605ae2172dd53e1e3e34baa8 Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Mon, 10 Feb 2020 18:00:37 +0100 Subject: Correcting diskio write units in grafana dashboard --- conf/glances-grafana.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/glances-grafana.json b/conf/glances-grafana.json index 9f5c7c77..4d6cda5b 100644 --- a/conf/glances-grafana.json +++ b/conf/glances-grafana.json @@ -1335,7 +1335,7 @@ "show": true }, { - "format": "short", + "format": "bytes", "logBase": 1, "max": null, "min": null, -- cgit v1.2.3 From b6727ad42e6d315a208902070cb239af884dc96c Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Mon, 10 Feb 2020 18:42:25 +0100 Subject: Requirement for elasticsearch library for export --- docs/gw/elastic.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/gw/elastic.rst b/docs/gw/elastic.rst index f0897f02..2c247fa8 100644 --- a/docs/gw/elastic.rst +++ b/docs/gw/elastic.rst @@ -2,6 +2,8 @@ Elasticsearch ============= +.. note:: + You need to install the `elasticsearch`_ library on your system. You can export statistics to an ``Elasticsearch`` server. The connection should be defined in the Glances configuration file as following: @@ -36,3 +38,5 @@ get the CPU system stats: "value": "2.2" } } + +.. _elasticsearch: https://pypi.org/project/elasticsearch/ -- cgit v1.2.3 From 97916d2126eb575d37ad8ed7eccaaa30f9c65f4f Mon Sep 17 00:00:00 2001 From: fcalvet <38648518+fcalvet@users.noreply.github.com> Date: Tue, 11 Feb 2020 09:11:33 +0100 Subject: fix GPU memory consumption reporting Reverting changes in d434333dfe8f377989537ddad2296215fd6f78b5 which displayed something else than memory usage. Old calculation with new py3nvml module still aligns with nvidia-smi output --- glances/plugins/glances_gpu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glances/plugins/glances_gpu.py b/glances/plugins/glances_gpu.py index cf588216..9fd1c292 100644 --- a/glances/plugins/glances_gpu.py +++ b/glances/plugins/glances_gpu.py @@ -292,7 +292,8 @@ def get_device_name(device_handle): def get_mem(device_handle): """Get GPU device memory consumption in percent.""" try: - return pynvml.nvmlDeviceGetUtilizationRates(device_handle).memory + memory_info = pynvml.nvmlDeviceGetMemoryInfo(device_handle) + return memory_info.used * 100.0 / memory_info.total except pynvml.NVMLError: return None -- cgit v1.2.3 From 26cce71222043d0dfdd96e8e95bcaddd9e5b574f Mon Sep 17 00:00:00 2001 From: Bartlomiej Cieszkowski Date: Sun, 16 Feb 2020 19:20:31 +0100 Subject: text wrap was due to size of screen being different than subwindows size, use term_window sizing --- glances/outputs/glances_curses.py | 49 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index b78c9857..ff07a642 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -480,7 +480,7 @@ class _GlancesCurses(object): plugin_max_width = None if p in self._left_sidebar: plugin_max_width = max(self._left_sidebar_min_width, - self.screen.getmaxyx()[1] - 105) + self.term_window.getmaxyx()[1] - 105) plugin_max_width = min(self._left_sidebar_max_width, plugin_max_width) @@ -516,7 +516,7 @@ class _GlancesCurses(object): # Adapt number of processes to the available space max_processes_displayed = ( - self.screen.getmaxyx()[0] - 11 - + self.term_window.getmaxyx()[0] - 11 - (0 if 'docker' not in __stat_display else self.get_stats_display_height(__stat_display["docker"])) - (0 if 'processcount' not in __stat_display else @@ -619,7 +619,7 @@ class _GlancesCurses(object): l_uptime += self.get_stats_display_width(stat_display[i]) self.display_plugin( stat_display["system"], - display_optional=(self.screen.getmaxyx()[1] >= l_uptime)) + display_optional=(self.term_window.getmaxyx()[1] >= l_uptime)) self.space_between_column = 3 if 'ip' in stat_display: self.new_column() @@ -658,9 +658,9 @@ class _GlancesCurses(object): if not self.args.disable_quicklook: # Quick look is in the place ! if self.args.full_quicklook: - quicklook_width = self.screen.getmaxyx()[1] - (stats_width + 8 + stats_number * self.space_between_column) + quicklook_width = self.term_window.getmaxyx()[1] - (stats_width + 8 + stats_number * self.space_between_column) else: - quicklook_width = min(self.screen.getmaxyx()[1] - (stats_width + 8 + stats_number * self.space_between_column), + quicklook_width = min(self.term_window.getmaxyx()[1] - (stats_width + 8 + stats_number * self.space_between_column), self._quicklook_max_width - 5) try: stat_display["quicklook"] = stats.get_plugin( @@ -680,14 +680,14 @@ class _GlancesCurses(object): for p in self._top: plugin_display_optional[p] = True if stats_number > 1: - self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) + self.space_between_column = max(1, int((self.term_window.getmaxyx()[1] - stats_width) / (stats_number - 1))) for p in ['mem', 'cpu']: # No space ? Remove optional stats if self.space_between_column < 3: plugin_display_optional[p] = False plugin_widths[p] = self.get_stats_display_width(stat_display[p], without_option=True) if hasattr(self.args, 'disable_' + p) else 0 stats_width = sum(itervalues(plugin_widths)) + 1 - self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) + self.space_between_column = max(1, int((self.term_window.getmaxyx()[1] - stats_width) / (stats_number - 1))) else: self.space_between_column = 0 @@ -727,7 +727,7 @@ class _GlancesCurses(object): docker + processcount + amps + processlist + alert """ # Do not display anything if space is not available... - if self.screen.getmaxyx()[1] < self._left_sidebar_min_width: + if self.term_window.getmaxyx()[1] < self._left_sidebar_min_width: return # Restore line position @@ -744,9 +744,9 @@ class _GlancesCurses(object): self.new_line() if p == 'processlist': self.display_plugin(stat_display['processlist'], - display_optional=(self.screen.getmaxyx()[1] > 102), + display_optional=(self.term_window.getmaxyx()[1] > 102), display_additional=(not MACOS), - max_y=(self.screen.getmaxyx()[0] - self.get_stats_display_height(stat_display['alert']) - 2)) + max_y=(self.term_window.getmaxyx()[0] - self.get_stats_display_height(stat_display['alert']) - 2)) else: self.display_plugin(stat_display[p]) @@ -780,8 +780,8 @@ class _GlancesCurses(object): size_x += input_size if size_y is None: size_y = len(sentence_list) + 4 - screen_x = self.screen.getmaxyx()[1] - screen_y = self.screen.getmaxyx()[0] + screen_x = self.term_window.getmaxyx()[1] + screen_y = self.term_window.getmaxyx()[0] if size_x > screen_x or size_y > screen_y: # No size to display the popup => abord return False @@ -798,7 +798,7 @@ class _GlancesCurses(object): for y, m in enumerate(message.split('\n')): popup.addnstr(2 + y, 2, m, len(m)) - if is_input and not WINDOWS: + if is_input: # Create a subwindow for the text field subpop = popup.derwin(1, input_size, 2, 2 + len(m)) subpop.attron(self.colors_list['FILTER']) @@ -848,8 +848,8 @@ class _GlancesCurses(object): return 0 # Get the screen size - screen_x = self.screen.getmaxyx()[1] - screen_y = self.screen.getmaxyx()[0] + screen_x = self.term_window.getmaxyx()[1] + screen_y = self.term_window.getmaxyx()[0] # Set the upper/left position of the message if plugin_stats['align'] == 'right': @@ -1034,15 +1034,14 @@ class GlancesCursesClient(_GlancesCurses): pass -if not WINDOWS: - class GlancesTextbox(Textbox, object): +class GlancesTextbox(Textbox, object): - def __init__(self, *args, **kwargs): - super(GlancesTextbox, self).__init__(*args, **kwargs) + def __init__(self, *args, **kwargs): + super(GlancesTextbox, self).__init__(*args, **kwargs) - def do_command(self, ch): - if ch == 10: # Enter - return 0 - if ch == 127: # Back - return 8 - return super(GlancesTextbox, self).do_command(ch) + def do_command(self, ch): + if ch == 10: # Enter + return 0 + if ch == 127: # Back + return 8 + return super(GlancesTextbox, self).do_command(ch) -- cgit v1.2.3 From 76c8492832a5f234d4a2c41c20482336231845f8 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 13:56:06 +0100 Subject: FS filtering can be done on device name #1606 --- docs/aoa/fs.rst | 9 ++++++++- glances/plugins/glances_fs.py | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/aoa/fs.rst b/docs/aoa/fs.rst index 923c97f3..38c56097 100644 --- a/docs/aoa/fs.rst +++ b/docs/aoa/fs.rst @@ -37,10 +37,17 @@ system: Also, you can hide mount points as well (in the following ``/boot``): + +.. code-block:: ini + +[fs] +hide=/boot.* +Filtering can also be done on device name (Glances 3.1.4 or higher): + .. code-block:: ini [fs] - hide=/boot.* + hide=/dev/sdb2 RAID ---- diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py index 37a125d6..bc0a981d 100644 --- a/glances/plugins/glances_fs.py +++ b/glances/plugins/glances_fs.py @@ -114,7 +114,8 @@ class Plugin(GlancesPlugin): # Loop over fs for fs in fs_stat: # Do not take hidden file system into account - if self.is_hide(fs.mountpoint): + # Also check device name (see issue #1606) + if self.is_hide(fs.mountpoint) or self.is_hide(fs.device): continue # Grab the disk usage try: @@ -163,7 +164,11 @@ class Plugin(GlancesPlugin): 'used': used, 'percent': percent, 'key': self.get_key()} - stats.append(fs_current) + # Do not take hidden file system into account + if self.is_hide(fs_current['mnt_point']): + continue + else: + stats.append(fs_current) else: # Default behavior for fs in fs_stat: @@ -174,7 +179,11 @@ class Plugin(GlancesPlugin): 'used': int(fs_stat[fs]['used']) * 1024, 'percent': float(fs_stat[fs]['percent']), 'key': self.get_key()} - stats.append(fs_current) + # Do not take hidden file system into account + if self.is_hide(fs_current['mnt_point']) or self.is_hide(fs_current['device_name']): + continue + else: + stats.append(fs_current) # Update the stats self.stats = stats -- cgit v1.2.3 From 10965a1a7cb625b570ee14348d12a3dc81fd7e35 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 14:15:03 +0100 Subject: NameError: name logger is not defined in net plugin #1602 --- glances/plugins/glances_network.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index 90b41090..00fc88b0 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -26,6 +26,7 @@ import operator from glances.timer import getTimeSinceLastUpdate from glances.plugins.glances_plugin import GlancesPlugin from glances.compat import n, u, b, nativestr +from glances.logger import logger import psutil -- cgit v1.2.3 From 4369cd76622795397327e4bbc58eeb531aa685bb Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 14:33:06 +0100 Subject: Debug message for issue #1604 --- glances/plugins/glances_load.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/glances/plugins/glances_load.py b/glances/plugins/glances_load.py index 891a7eb9..e3e2cc13 100644 --- a/glances/plugins/glances_load.py +++ b/glances/plugins/glances_load.py @@ -25,6 +25,7 @@ import psutil from glances.compat import iteritems from glances.plugins.glances_core import Plugin as CorePlugin from glances.plugins.glances_plugin import GlancesPlugin +from glances.logger import logger # SNMP OID # 1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1 @@ -62,7 +63,8 @@ class Plugin(GlancesPlugin): # Call CorePlugin in order to display the core number try: self.nb_log_core = CorePlugin(args=self.args).update()["log"] - except Exception: + except Exception as e: + logger.debug('Error: Can not retrieve the CPU core number (set it to 1) ({})'.format(e)) self.nb_log_core = 1 def _getloadavg(self): @@ -142,11 +144,11 @@ class Plugin(GlancesPlugin): # Build the string message # Header - msg = '{:8}'.format('LOAD%' if (args.disable_irix and self.nb_log_core != 0) else 'LOAD') + msg = '{:6}'.format('LOAD%' if (args.disable_irix and self.nb_log_core != 0) else 'LOAD') ret.append(self.curse_add_line(msg, "TITLE")) # Core number if 'cpucore' in self.stats and self.stats['cpucore'] > 0: - msg = '{}-core'.format(int(self.stats['cpucore'])) + msg = '{:3}-core'.format(int(self.stats['cpucore'])) ret.append(self.curse_add_line(msg)) # Loop over 1min, 5min and 15min load for load_time in ['1', '5', '15']: -- cgit v1.2.3 From 1e8bf7bd5fdec1d2b8eb85e57a38096466f1b5d9 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 14:59:52 +0100 Subject: Glances don't want to run on Crostini (LXC Container, Debian 10, python 3.7.3) #1600 --- glances/processes.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/glances/processes.py b/glances/processes.py index 29024bf5..f1291d59 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -64,6 +64,28 @@ class GlancesProcesses(object): # Extended stats for top process is enable by default self.disable_extended_tag = False + # Test if the system can grab io_counters + try: + p = psutil.Process() + p.io_counters() + except Exception as e: + logger.warning('PsUtil can not grab processes io_counters ({})'.format(e)) + self.disable_io_counters = True + else: + logger.debug('PsUtil can grab processes io_counters') + self.disable_io_counters = False + + # Test if the system can grab gids + try: + p = psutil.Process() + p.gids() + except Exception as e: + logger.warning('PsUtil can not grab processes gids ({})'.format(e)) + self.disable_gids = True + else: + logger.debug('PsUtil can grab processes gids') + self.disable_gids = False + # Maximum number of processes showed in the UI (None if no limit) self._max_processes = None @@ -237,11 +259,9 @@ class GlancesProcesses(object): standard_attrs = ['cmdline', 'cpu_percent', 'cpu_times', 'memory_info', 'memory_percent', 'name', 'nice', 'pid', 'ppid', 'status', 'username', 'status', 'num_threads'] - # io_counters availability: Linux, BSD, Windows, AIX - if not MACOS and not SUNOS and not WSL: + if not self.disable_io_counters: standard_attrs += ['io_counters'] - # gids availability: Unix - if not WINDOWS: + if not self.disable_gids: standard_attrs += ['gids'] # and build the processes stats list (psutil>=5.3.0) -- cgit v1.2.3 From f6533272a5a61d13a4041d84c43adeffee926aef Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 15:17:24 +0100 Subject: Feature request: Include hostname in all (e.g. kafka) exports #1594 --- conf/glances.conf | 4 ++++ docs/gw/influxdb.rst | 5 ++++- docs/gw/kafka.rst | 6 +++++- glances/exports/glances_kafka.py | 9 +++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/conf/glances.conf b/conf/glances.conf index 5a177068..9ffe1713 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -488,6 +488,10 @@ host=localhost port=9092 topic=glances #compression=gzip +# Tags will be added for all events +#tags=foo:bar,spam:eggs +# You can also use dynamic values +#tags=hostname:`hostname -f` [zeromq] # Configuration for the --export zeromq option diff --git a/docs/gw/influxdb.rst b/docs/gw/influxdb.rst index a14f75c8..43db9df9 100644 --- a/docs/gw/influxdb.rst +++ b/docs/gw/influxdb.rst @@ -16,7 +16,10 @@ following: user=root password=root db=glances - tags=foo:bar,spam:eggs + # Tags will be added for all measurements + #tags=foo:bar,spam:eggs + # You can also use dynamic values + #tags=system:`uname -s` and run Glances with: diff --git a/docs/gw/kafka.rst b/docs/gw/kafka.rst index 2bfe532a..6e3dedf3 100644 --- a/docs/gw/kafka.rst +++ b/docs/gw/kafka.rst @@ -14,6 +14,10 @@ following: port=9092 topic=glances #compression=gzip + # Tags will be added for all events + #tags=foo:bar,spam:eggs + # You can also use dynamic values + #tags=hostname:`hostname -f` Note: you can enable the compression but it consume CPU on your host. @@ -43,4 +47,4 @@ Python code example to consume Kafka Glances plugin: consumer = KafkaConsumer('glances', value_deserializer=json.loads) for s in consumer: - print s + print(s) diff --git a/glances/exports/glances_kafka.py b/glances/exports/glances_kafka.py index c328d7f6..88d13bf0 100644 --- a/glances/exports/glances_kafka.py +++ b/glances/exports/glances_kafka.py @@ -42,11 +42,14 @@ class Export(GlancesExport): # Optionals configuration keys self.compression = None + self.tags = None # Load the Kafka configuration file section self.export_enable = self.load_conf('kafka', - mandatories=['host', 'port', 'topic'], - options=['compression']) + mandatories=['host', 'port', + 'topic'], + options=['compression', + 'tags']) if not self.export_enable: sys.exit(2) @@ -79,6 +82,8 @@ class Export(GlancesExport): # Create DB input data = dict(zip(columns, points)) + if self.tags is not None: + data.update(self.parse_tags(self.tags)) # Send stats to the kafka topic # key= -- cgit v1.2.3 From 62dbeb369efe8bb6c09b719835463ba71d2cec09 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 27 Feb 2020 15:28:28 +0100 Subject: Kafka key name needs to be bytes #1593 --- glances/exports/glances_kafka.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glances/exports/glances_kafka.py b/glances/exports/glances_kafka.py index 88d13bf0..f5a6127e 100644 --- a/glances/exports/glances_kafka.py +++ b/glances/exports/glances_kafka.py @@ -27,6 +27,7 @@ from glances.exports.glances_export import GlancesExport from kafka import KafkaProducer import json +import codecs class Export(GlancesExport): @@ -90,7 +91,8 @@ class Export(GlancesExport): # value=JSON dict try: self.client.send(self.topic, - key=name, + # Kafka key name needs to be bytes #1593 + key=name.encode('utf-8'), value=data) except Exception as e: logger.error("Cannot export {} stats to Kafka ({})".format(name, e)) -- cgit v1.2.3 From 2c9e80b4a5d29b6c99ecfd94d6c186d5fa6cbc21 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Tue, 3 Mar 2020 22:10:42 +0100 Subject: [diskio] Aliases Display Incorrectly/Not at All, and Glances Throws Error on Exit #1618 --- conf/glances.conf | 2 +- glances/plugins/glances_diskio.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/glances.conf b/conf/glances.conf index 9ffe1713..d5cf291e 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -170,7 +170,7 @@ disable=False #hide=sda2,sda5,loop.* hide=loop.*,/dev/loop* # Alias for sda1 -#sda1_alias=IntDisk +#sda1_alias=InternalDisk [fs] disable=False diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index eb339d2d..52ddfebc 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -162,7 +162,7 @@ class Plugin(GlancesPlugin): return ret # Max size for the interface name - name_max_width = max_width - 12 + name_max_width = max_width - 13 # Header msg = '{:{width}}'.format('DISK I/O', width=name_max_width) @@ -188,9 +188,9 @@ class Plugin(GlancesPlugin): ret.append(self.curse_new_line()) if len(disk_name) > name_max_width: # Cut disk name if it is too long - disk_name = '_' + disk_name[-name_max_width:] + disk_name = '_' + disk_name[-name_max_width+1:] msg = '{:{width}}'.format(nativestr(disk_name), - width=name_max_width) + width=name_max_width+1) ret.append(self.curse_add_line(msg)) if args.diskio_iops: # count -- cgit v1.2.3 From 105aa65f2117bd3af42292cf1a5f90abd0f78323 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Tue, 3 Mar 2020 22:19:23 +0100 Subject: Correct an issue on Windows, time zone not display correctly. Skip it for the moment --- glances/plugins/glances_now.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/glances/plugins/glances_now.py b/glances/plugins/glances_now.py index 85f4ece1..c549335a 100644 --- a/glances/plugins/glances_now.py +++ b/glances/plugins/glances_now.py @@ -22,6 +22,7 @@ from time import tzname, localtime from datetime import datetime +from glances.globals import WINDOWS from glances.plugins.glances_plugin import GlancesPlugin @@ -49,11 +50,12 @@ class Plugin(GlancesPlugin): """Update current date/time.""" # Had to convert it to string because datetime is not JSON serializable self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S') - # Add the time zone (issue #1249 and issue #1337) - if 'tmzone' in localtime(): - self.stats += ' {}'.format(localtime().tm_zone) - elif len(tzname) > 0: - self.stats += ' {}'.format(tzname[1]) + # Add the time zone (issue #1249 / #1337 / #1598) + if not WINDOWS: + if 'tmzone' in localtime(): + self.stats += ' {}'.format(localtime().tm_zone) + elif len(tzname) > 0: + self.stats += ' {}'.format(tzname[1]) return self.stats -- cgit v1.2.3 From 547062750b28a9f03700d956535eb38a55571281 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Tue, 3 Mar 2020 22:29:39 +0100 Subject: Update doc --- docs/glances.rst | 7 +++---- docs/man/glances.1 | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/glances.rst b/docs/glances.rst index 336088ec..0d1bde4e 100644 --- a/docs/glances.rst +++ b/docs/glances.rst @@ -38,13 +38,12 @@ Monitor local machine (standalone mode): $ glances -Note: The standalone mode is not available on Microsoft Windows (c). -Glances will start in Web server mode on this operating system. - -Monitor local machine with the web interface (Web UI): +Monitor local machine with the web interface (Web UI), run the following command line: $ glances -w +and open a Web browser with the returned URL + Monitor local machine and export stats to a CSV file: $ glances --export csv --export-csv-file /tmp/glances.csv diff --git a/docs/man/glances.1 b/docs/man/glances.1 index a7539c3c..9e52de68 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLANCES" "1" "Dec 26, 2019" "3.1.4_BETA" "Glances" +.TH "GLANCES" "1" "Mar 03, 2020" "3.1.4_BETA" "Glances" .SH NAME glances \- An eye on your system . @@ -775,16 +775,15 @@ $ glances .UNINDENT .UNINDENT .sp -Note: The standalone mode is not available on Microsoft Windows (c). -Glances will start in Web server mode on this operating system. -.sp -Monitor local machine with the web interface (Web UI): +Monitor local machine with the web interface (Web UI), run the following command line: .INDENT 0.0 .INDENT 3.5 $ glances \-w .UNINDENT .UNINDENT .sp +and open a Web browser with the returned URL +.sp Monitor local machine and export stats to a CSV file: .INDENT 0.0 .INDENT 3.5 @@ -839,6 +838,6 @@ $ glances –browser .sp Nicolas Hennion aka Nicolargo <\fI\%contact@nicolargo.com\fP> .SH COPYRIGHT -2019, Nicolas Hennion +2020, Nicolas Hennion .\" Generated by docutils manpage writer. . -- cgit v1.2.3