From 3a9ec4e4a85d9f2845d8044053f4f50c777aa8af Mon Sep 17 00:00:00 2001 From: Nicolas Hennion Date: Wed, 26 May 2021 14:18:27 +0200 Subject: [PATCH] Make the Docker API connection timeout configurable --- conf/glances.conf | 2 ++ glances/plugins/glances_docker.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/glances.conf b/conf/glances.conf index 3c2e7046..a25fc9d2 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -351,6 +351,8 @@ port_default_gateway=True [docker] disable=False +# Timeout for API calls (in seconds, default is 1) +timeout=1 # Only show specific containers (comma separeted list of container name or regular expression) # Comment this line to display all containers (default configuration) #show=telegraf diff --git a/glances/plugins/glances_docker.py b/glances/plugins/glances_docker.py index de62be98..ce648b92 100644 --- a/glances/plugins/glances_docker.py +++ b/glances/plugins/glances_docker.py @@ -137,7 +137,7 @@ class Plugin(GlancesPlugin): def connect(self): """Connect to the Docker server.""" try: - ret = docker.from_env() + ret = docker.from_env(timeout=int(self.get_conf_value('timeout', '1'))) except Exception as e: logger.error("docker plugin - Can not connect to Docker ({})".format(e)) ret = None -- GitLab