Skip to content

Commit

Permalink
[ceph] split the ceph plugin
Browse files Browse the repository at this point in the history
This work distributes the ceph plugin into plugins
for individual ceph components (mon,osd,mds,rgw,mgr),
so that additional data collection can then be added
in each of the components. Work for additional data
collection in each component plugin will follow in
a later commit.

Closes: #1945

Signed-off-by: Nikhil Kshirsagar <nkshirsagar@gmail.com>
  • Loading branch information
nkshirsagar authored and TurboTurtle committed Sep 24, 2021
1 parent aaeb8cb commit 13ce811
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 94 deletions.
85 changes: 85 additions & 0 deletions sos/report/plugins/ceph_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin
from socket import gethostname


class Ceph_Common(Plugin, RedHatPlugin, UbuntuPlugin):

short_desc = 'CEPH common'

plugin_name = 'ceph_common'
profiles = ('storage', 'virt', 'container')

containers = ('ceph-(mon|rgw|osd).*',)
ceph_hostname = gethostname()

packages = (
'ceph',
'ceph-mds',
'ceph-common',
'libcephfs1',
'ceph-fs-common',
'calamari-server',
'librados2'
)

services = (
'ceph-nfs@pacemaker',
'ceph-mds@%s' % ceph_hostname,
'ceph-mon@%s' % ceph_hostname,
'ceph-mgr@%s' % ceph_hostname,
'ceph-radosgw@*',
'ceph-osd@*'
)

# This check will enable the plugin regardless of being
# containerized or not
files = ('/etc/ceph/ceph.conf',)

def setup(self):
all_logs = self.get_option("all_logs")

self.add_file_tags({
'.*/ceph.conf': 'ceph_conf',
'/var/log/ceph/ceph.log.*': 'ceph_log',
})

if not all_logs:
self.add_copy_spec("/var/log/calamari/*.log",)
else:
self.add_copy_spec("/var/log/calamari",)

self.add_copy_spec([
"/var/log/ceph/ceph.log",
"/var/log/ceph/ceph.audit.log*",
"/var/log/calamari/*.log",
"/etc/ceph/",
"/etc/calamari/",
"/var/lib/ceph/tmp/",
])

self.add_cmd_output([
"ceph -v",
])

self.add_forbidden_path([
"/etc/ceph/*keyring*",
"/var/lib/ceph/*keyring*",
"/var/lib/ceph/*/*keyring*",
"/var/lib/ceph/*/*/*keyring*",
"/var/lib/ceph/osd",
"/var/lib/ceph/mon",
# Excludes temporary ceph-osd mount location like
# /var/lib/ceph/tmp/mnt.XXXX from sos collection.
"/var/lib/ceph/tmp/*mnt*",
"/etc/ceph/*bindpass*"
])

# vim: set et ts=4 sw=4 :
48 changes: 48 additions & 0 deletions sos/report/plugins/ceph_mds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin
import glob


class CephMDS(Plugin, RedHatPlugin, UbuntuPlugin):
short_desc = 'CEPH mds'
plugin_name = 'ceph_mds'
profiles = ('storage', 'virt', 'container')
containers = ('ceph-fs.*',)

def check_enabled(self):
return True if glob.glob('/var/lib/ceph/mds/*/*') else False

def setup(self):
self.add_file_tags({
'/var/log/ceph/ceph-mds.*.log': 'ceph_mds_log',
})

self.add_copy_spec([
"/var/log/ceph.log",
"/var/log/ceph/ceph-mds*.log",
"/var/lib/ceph/bootstrap-mds/",
"/var/lib/ceph/mds/",
"/run/ceph/ceph-mds*",
])

self.add_forbidden_path([
"/etc/ceph/*keyring*",
"/var/lib/ceph/*keyring*",
"/var/lib/ceph/*/*keyring*",
"/var/lib/ceph/*/*/*keyring*",
"/var/lib/ceph/osd",
"/var/lib/ceph/mon",
# Excludes temporary ceph-osd mount location like
# /var/lib/ceph/tmp/mnt.XXXX from sos collection.
"/var/lib/ceph/tmp/*mnt*",
"/etc/ceph/*bindpass*"
])

# vim: set et ts=4 sw=4 :
81 changes: 81 additions & 0 deletions sos/report/plugins/ceph_mgr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin
import glob


class CephMGR(Plugin, RedHatPlugin, UbuntuPlugin):

short_desc = 'CEPH mgr'

plugin_name = 'ceph_mgr'
profiles = ('storage', 'virt', 'container')

containers = ('ceph-mgr.*',)

def check_enabled(self):
return True if glob.glob('/var/lib/ceph/mgr/*/*') else False

def setup(self):
self.add_file_tags({
'/var/log/ceph/ceph-mgr.*.log': 'ceph_mgr_log',
})

self.add_copy_spec([
"/var/log/ceph/ceph-mgr*.log",
"/var/lib/ceph/mgr/",
"/var/lib/ceph/bootstrap-mgr/",
"/run/ceph/ceph-mgr*",
])

# more commands to be added later
self.add_cmd_output([
"ceph balancer status",
"ceph mgr metadata",
])

# more commands to be added later
ceph_cmds = [
"mgr module ls",
"mgr dump",
]

self.add_cmd_output([
"ceph %s --format json-pretty" % s for s in ceph_cmds
], subdir="json_output", tags="insights_ceph_health_detail")

self.add_forbidden_path([
"/etc/ceph/*keyring*",
"/var/lib/ceph/*keyring*",
"/var/lib/ceph/*/*keyring*",
"/var/lib/ceph/*/*/*keyring*",
"/var/lib/ceph/osd",
"/var/lib/ceph/mon",
# Excludes temporary ceph-osd mount location like
# /var/lib/ceph/tmp/mnt.XXXX from sos collection.
"/var/lib/ceph/tmp/*mnt*",
"/etc/ceph/*bindpass*",
])

# If containerized, run commands in containers
containers_list = self.get_all_containers_by_regex("ceph-mgr*")
if containers_list:
for container in containers_list:
self.add_cmd_output([
self.fmt_container_cmd(container[1], "ceph %s" % s)
for s in ceph_cmds
])
break
# Not containerized
else:
self.add_cmd_output([
"ceph %s" % s for s in ceph_cmds
])

# vim: set et ts=4 sw=4 :
Loading

0 comments on commit 13ce811

Please sign in to comment.