From bc34d9b938f9cd1c53120fc8badc3dff600771d3 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Fri, 15 Feb 2019 16:23:36 -0500 Subject: [docker] Don't run docker commands when the service is not running Prevents the docker plugin from running docker commands when the service is not running. This will prevent us from collecting the same 'docker is not running' error message over and over again from the docker commands that would otherwise get run. Signed-off-by: Jake Hunsaker --- sos/plugins/docker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sos/plugins/docker.py b/sos/plugins/docker.py index 5b2acff5..69ac997e 100644 --- a/sos/plugins/docker.py +++ b/sos/plugins/docker.py @@ -33,6 +33,14 @@ class Docker(Plugin): "/var/lib/docker/repositories-*" ]) + self.add_journal(units="docker") + self.add_cmd_output("ls -alhR /etc/docker") + + if not self.service_is_running('docker'): + # if docker is not running none of the below commands will provide + # any useful output + return + subcmds = [ 'events --since 24h --until 1s', 'info', @@ -53,9 +61,6 @@ class Docker(Plugin): if self.get_option('size'): self.add_cmd_output('docker ps -as') - self.add_journal(units="docker") - self.add_cmd_output("ls -alhR /etc/docker") - nets = self.get_command_output('docker network ls') if nets['status'] == 0: -- cgit