Blame SOURCES/sos-bz1351647-docker-more-data-expand-options.patch

69a90f
From 9d1344055948aecdce77d55893eeb46e288ecbcd Mon Sep 17 00:00:00 2001
69a90f
From: Jake Hunsaker <jhunsake@redhat.com>
69a90f
Date: Mon, 11 Jan 2016 10:11:21 -0500
69a90f
Subject: [PATCH] [docker] Gather more data and expand plugin options
69a90f
69a90f
This patch changes the behavior of the docker plugin and collects a bit more
69a90f
data than before. In addition, it also adds 'docker-engine' to the package lists
69a90f
as that is the current name of the community release of Docker.
69a90f
69a90f
Both 'docker version' and 'docker ps -a' output is now collected. Output from
69a90f
'docker version' help to validate a given docker binary and 'ps -a' output is
69a90f
collected to see all terminated, but still existing, containers present on the
69a90f
system. This is kept separate from normal 'ps' output to keep it simple to only
69a90f
quickly look at running containers.
69a90f
69a90f
The output of 'docker inspect' is now collected as well, by default only for
69a90f
running containers.
69a90f
69a90f
Further, plugin options have been changed:
69a90f
69a90f
- 'logs' will now capture 'docker logs' output for all running containers.
69a90f
Previously this was provided by the 'all' option which would also always include
69a90f
terminated containers.
69a90f
69a90f
- 'all' will now cause the plugin to also include terminated containers for
69a90f
'inspect' and 'logs' output. Note that by itself this option no longer captures any
69a90f
additional information.
69a90f
69a90f
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
69a90f
---
69a90f
 sos/plugins/docker.py | 49 ++++++++++++++++++++++++++++++++-----------------
69a90f
 1 file changed, 32 insertions(+), 17 deletions(-)
69a90f
69a90f
diff --git a/sos/plugins/docker.py b/sos/plugins/docker.py
69a90f
index 8c87bfa..452cf76 100644
69a90f
--- a/sos/plugins/docker.py
69a90f
+++ b/sos/plugins/docker.py
69a90f
@@ -23,39 +23,54 @@ class Docker(Plugin):
69a90f
 
69a90f
     plugin_name = 'docker'
69a90f
     profiles = ('virt',)
69a90f
-    docker_bin = "docker"
69a90f
+    docker_cmd = "docker"
69a90f
 
69a90f
-    option_list = [("all", "capture all container logs even the "
69a90f
-                    "terminated ones", 'fast', False)]
69a90f
+    option_list = [
69a90f
+        ("all", "enable capture for all containers, even containers "
69a90f
+            "that have terminated", 'fast', False),
69a90f
+        ("logs", "capture logs for running containers",
69a90f
+            'fast', False)
69a90f
+    ]
69a90f
 
69a90f
     def setup(self):
69a90f
         self.add_copy_spec([
69a90f
             "/var/lib/docker/repositories-*"
69a90f
         ])
69a90f
 
69a90f
-        self.add_cmd_output([
69a90f
-            "{0} info".format(self.docker_bin),
69a90f
-            "{0} ps".format(self.docker_bin),
69a90f
-            "{0} images".format(self.docker_bin)
69a90f
-        ])
69a90f
+        for subcmd in ['info', 'ps', 'ps -a', 'images', 'version']:
69a90f
+            self.add_cmd_output(
69a90f
+                "{0} {1}".format(self.docker_cmd, subcmd)
69a90f
+            )
69a90f
+
69a90f
         self.add_journal(units="docker")
69a90f
 
69a90f
-        ps_cmd = "{0} ps".format(self.docker_bin)
69a90f
+        ps_cmd = "{0} ps -q".format(self.docker_cmd)
69a90f
         if self.get_option('all'):
69a90f
             ps_cmd = "{0} -a".format(ps_cmd)
69a90f
 
69a90f
         result = self.get_command_output(ps_cmd)
69a90f
         if result['status'] == 0:
69a90f
-            for line in result['output'].splitlines()[1:]:
69a90f
-                container_id = line.split(" ")[0]
69a90f
-                self.add_cmd_output([
69a90f
-                    "{0} logs {1}".format(self.docker_bin, container_id)
69a90f
-                ])
69a90f
+            containers = [c for c in result['output'].splitlines()]
69a90f
+            for container in containers:
69a90f
+                self.add_cmd_output(
69a90f
+                    "{0} inspect {1}".format(
69a90f
+                        self.docker_cmd,
69a90f
+                        container
69a90f
+                    )
69a90f
+                )
69a90f
+            if self.get_option('logs'):
69a90f
+                for container in containers:
69a90f
+                    self.add_cmd_output(
69a90f
+                        "{0} logs {1}".format(
69a90f
+                            self.docker_cmd,
69a90f
+                            container
69a90f
+                        )
69a90f
+                    )
69a90f
 
69a90f
 
69a90f
 class RedHatDocker(Docker, RedHatPlugin):
69a90f
 
69a90f
-    packages = ('docker', 'docker-io')
69a90f
+    packages = ('docker', 'docker-latest', 'docker-io', 'docker-engine')
69a90f
 
69a90f
     def setup(self):
69a90f
         super(RedHatDocker, self).setup()
69a90f
@@ -67,10 +82,10 @@ class RedHatDocker(Docker, RedHatPlugin):
69a90f
 
69a90f
 class UbuntuDocker(Docker, UbuntuPlugin):
69a90f
 
69a90f
-    packages = ('docker.io',)
69a90f
+    packages = ('docker.io', 'docker-engine')
69a90f
 
69a90f
     # Name collision with another package requires docker binary rename
69a90f
-    docker_bin = 'docker.io'
69a90f
+    docker_cmd = 'docker.io'
69a90f
 
69a90f
     def setup(self):
69a90f
         super(UbuntuDocker, self).setup()
69a90f
-- 
69a90f
2.4.11
69a90f