From a8e01f0df98cac4e6878b5101306e6fdc5509b4d Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Thu, 30 Apr 2020 20:13:23 +0200 Subject: [PATCH] [modules/docker] Exception when daemon is not running When the docker daemon is not running, only the call to containers.list() actually throws an exception, so move that into the exception guard. fixes #608 --- modules/contrib/docker_ps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/contrib/docker_ps.py b/modules/contrib/docker_ps.py index 044dd49..13b9f7f 100644 --- a/modules/contrib/docker_ps.py +++ b/modules/contrib/docker_ps.py @@ -33,11 +33,11 @@ class Module(core.module.Module): try: cli = docker.DockerClient(base_url='unix://var/run/docker.sock') cli.ping() + self.__info = 'OK - {}'.format(len(cli.containers.list(filters={'status': 'running'}))) except ConnectionError: self.__info = 'daemon off' except Exception: self.__info = 'n/a' - self.__info = 'OK - {}'.format(len(cli.containers.list(filters={'status': 'running'}))) return self.__info # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4