Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kdump support for COS #1548

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sos/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions sos/plugins/cgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
5 changes: 3 additions & 2 deletions sos/plugins/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
11 changes: 10 additions & 1 deletion sos/plugins/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 :
5 changes: 3 additions & 2 deletions sos/plugins/filesys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
23 changes: 22 additions & 1 deletion sos/plugins/kdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 :
5 changes: 3 additions & 2 deletions sos/plugins/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
22 changes: 21 additions & 1 deletion sos/plugins/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 :
5 changes: 3 additions & 2 deletions sos/plugins/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
5 changes: 3 additions & 2 deletions sos/plugins/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
5 changes: 3 additions & 2 deletions sos/plugins/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
24 changes: 24 additions & 0 deletions sos/policies/cos.py
Original file line number Diff line number Diff line change
@@ -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 :