Do not shorten container names #1723

This commit is contained in:
nicolargo 2020-09-12 11:01:48 +02:00
parent b1f6c24cfb
commit 0cc59ce3a3
3 changed files with 13 additions and 2 deletions

View File

@ -327,6 +327,8 @@ port_default_gateway=True
[docker]
disable=False
# Define the maximum docker size name (default is 20 chars)
max_name_size=20
#cpu_careful=50
# Thresholds for CPU and MEM (in %)
#cpu_warning=70

View File

@ -20,6 +20,9 @@ under the ``[docker]`` section:
.. code-block:: ini
[docker]
disable=False
# Define the maximum docker size name (default is 20 chars)
max_name_size=20
# Global containers' thresholds for CPU and MEM (in %)
cpu_careful=50
cpu_warning=70

View File

@ -81,6 +81,9 @@ class Plugin(GlancesPlugin):
# The plgin can be disable using: args.disable_docker
self.args = args
# Default config keys
self.config = config
# We want to display the stat in the curse interface
self.display_curse = True
@ -524,8 +527,11 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_new_line())
# Header
ret.append(self.curse_new_line())
# Get the maximum containers name (cutted to 20 char max)
name_max_width = min(20, len(max(self.stats['containers'], key=lambda x: len(x['name']))['name']))
# Get the maximum containers name
# Max size is configurable. See feature request #1723.
name_max_width = min(self.config.get_int_value('docker', 'max_name_size', default=20),
len(max(self.stats['containers'],
key=lambda x: len(x['name']))['name']))
msg = ' {:{width}}'.format('Name', width=name_max_width)
ret.append(self.curse_add_line(msg))
msg = '{:>10}'.format('Status')