diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index 82fef18e51..967757f244 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -1253,6 +1253,11 @@ class SuSEPlugin(object): pass +class CosPlugin(object): + """Tagging class for Container-Optimized OS distributions""" + pass + + class IndependentPlugin(object): """Tagging class for plugins that can run on any platform""" pass diff --git a/sos/plugins/cgroups.py b/sos/plugins/cgroups.py index f8d76a2dfd..cd7e832a30 100644 --- a/sos/plugins/cgroups.py +++ b/sos/plugins/cgroups.py @@ -6,10 +6,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Cgroups(Plugin, DebianPlugin, UbuntuPlugin): +class Cgroups(Plugin, DebianPlugin, UbuntuPlugin, CosPlugin): """Control groups subsystem """ diff --git a/sos/plugins/devices.py b/sos/plugins/devices.py index ad33d91e99..3f0a5e2bf0 100644 --- a/sos/plugins/devices.py +++ b/sos/plugins/devices.py @@ -6,10 +6,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Devices(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): +class Devices(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): """ devices specific commands """ diff --git a/sos/plugins/docker.py b/sos/plugins/docker.py index a44264a4cb..51a22d42be 100644 --- a/sos/plugins/docker.py +++ b/sos/plugins/docker.py @@ -8,7 +8,7 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin +from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin, CosPlugin class Docker(Plugin): @@ -110,4 +110,13 @@ def setup(self): "/var/run/docker/libcontainerd/containerd/events.log" ]) + +class CosDocker(Docker, CosPlugin): + + def setup(self): + super(CosDocker, self).setup() + self.add_copy_spec([ + "/etc/docker/daemon.json" + ]) + # vim: set et ts=4 sw=4 : diff --git a/sos/plugins/filesys.py b/sos/plugins/filesys.py index 3a721067cc..035c6f0e8b 100644 --- a/sos/plugins/filesys.py +++ b/sos/plugins/filesys.py @@ -6,10 +6,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Filesys(Plugin, DebianPlugin, UbuntuPlugin): +class Filesys(Plugin, DebianPlugin, UbuntuPlugin, CosPlugin): """Local file systems """ diff --git a/sos/plugins/kdump.py b/sos/plugins/kdump.py index 48522767e3..bef42738d3 100644 --- a/sos/plugins/kdump.py +++ b/sos/plugins/kdump.py @@ -6,7 +6,8 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) class KDump(Plugin): @@ -45,4 +46,24 @@ def setup(self): "/etc/default/kdump-tools" ]) + +class CosKDump(KDump, CosPlugin): + + option_list = [ + ("all_dumps", "enable capture for all kernel dumps", "", False), + ("latest_dump", "enable capture for latest kernel crash dump", "", False), + ] + + def setup(self): + super(CosLogs, self).setup() + self.add_cmd_output('ls -alRh /var/kdump*') + if self.get_option("all_dumps"): + self.add_copy_spec([ + "/var/kdump-*" + ]) + if self.get_option("latest_dump"): + self.add_copy_spec([ + "/var/kdump" + ]) + # vim: set et ts=4 sw=4 : diff --git a/sos/plugins/kernel.py b/sos/plugins/kernel.py index 7310932696..ab0e875252 100644 --- a/sos/plugins/kernel.py +++ b/sos/plugins/kernel.py @@ -6,13 +6,14 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) import os import glob import json -class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): +class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): """Linux kernel """ diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py index 66fbaebecd..1b6ca109c6 100644 --- a/sos/plugins/logs.py +++ b/sos/plugins/logs.py @@ -8,7 +8,8 @@ import os import glob -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) class Logs(Plugin): @@ -121,4 +122,23 @@ def setup(self): else: self.add_copy_spec("/var/log/") + +class CosLogs(Logs, CosPlugin): + + option_list = [ + ("log_days", "the number of days logs to collect", "", 3) + ] + + def setup(self): + super(CosLogs, self).setup() + self.add_cmd_output('ls -alRh /var/log/') + if self.get_option("all_logs"): + self.add_cmd_output("journalctl -o export") + else: + try: + days = int(self.get_option("log_days")) + except ValueError: + days = 3 + self.add_journal(since="-%ddays" % days) + # vim: set et ts=4 sw=4 : diff --git a/sos/plugins/memory.py b/sos/plugins/memory.py index 3bfb43f0a4..7baf207813 100644 --- a/sos/plugins/memory.py +++ b/sos/plugins/memory.py @@ -6,10 +6,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Memory(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): +class Memory(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): """Memory configuration and use """ diff --git a/sos/plugins/process.py b/sos/plugins/process.py index 755eec8d6f..9be759f923 100644 --- a/sos/plugins/process.py +++ b/sos/plugins/process.py @@ -6,10 +6,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Process(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): +class Process(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): """process information """ diff --git a/sos/plugins/systemd.py b/sos/plugins/systemd.py index 90d723ffbc..5544244990 100644 --- a/sos/plugins/systemd.py +++ b/sos/plugins/systemd.py @@ -8,10 +8,11 @@ # # See the LICENSE file in the source distribution for further information. -from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +from sos.plugins import (Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, + CosPlugin) -class Systemd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): +class Systemd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): """ System management daemon """ diff --git a/sos/policies/cos.py b/sos/policies/cos.py new file mode 100644 index 0000000000..acd9a4ab81 --- /dev/null +++ b/sos/policies/cos.py @@ -0,0 +1,24 @@ +from sos.plugins import CosPlugin +from sos.policies import LinuxPolicy + +import os + + +class CosPolicy(LinuxPolicy): + distro = "Container-Optimized OS" + vendor = "Google Cloud Platform" + vendor_url = "https://cloud.google.com/container-optimized-os/" + valid_subclasses = [CosPlugin] + PATH = "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin" + + @classmethod + def check(cls): + try: + with open('/etc/os-release', 'r') as fp: + os_release = dict(line.strip().split('=') for line in fp) + id = os_release.get('ID') + return id == 'cos' + except IOError: + return False + +# vim: set et ts=4 sw=4 :