Make the Docker API connection timeout configurable

pull/1873/head
Nicolas Hennion 2021-05-26 14:18:27 +02:00
parent 487a758edf
commit 3a9ec4e4a8
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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