summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2020-09-12 11:01:48 +0200
committernicolargo <nicolas@nicolargo.com>2020-09-12 11:01:48 +0200
commit0cc59ce3a30ab4402083d5de715368cdb506d764 (patch)
tree65a3722477698d99574bf221842ad36480daa3d2
parentb1f6c24cfb46cd1ac06f71e858dbe7a6ff9a9143 (diff)
Do not shorten container names #1723
-rw-r--r--conf/glances.conf2
-rw-r--r--docs/aoa/docker.rst3
-rw-r--r--glances/plugins/glances_docker.py10
3 files changed, 13 insertions, 2 deletions
diff --git a/conf/glances.conf b/conf/glances.conf
index f67db742..1502174e 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -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
diff --git a/docs/aoa/docker.rst b/docs/aoa/docker.rst
index 484dcd14..0fb440ff 100644
--- a/docs/aoa/docker.rst
+++ b/docs/aoa/docker.rst
@@ -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
diff --git a/glances/plugins/glances_docker.py b/glances/plugins/glances_docker.py
index 80c550df..3062404b 100644
--- a/glances/plugins/glances_docker.py
+++ b/glances/plugins/glances_docker.py
@@ -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')