diff options
author | Nobuto Murata <nobuto.murata@canonical.com> | 2023-01-05 11:26:18 +0900 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2023-01-30 15:29:26 -0500 |
commit | 554c8be31a40ff034cc19d70589cfbc9ee8e9def (patch) | |
tree | 9f63e3d7e0b81ad99a75845c8ea20c4a1dbd0618 | |
parent | 31b991ef2b51856264c911018eddea8dd55b5718 (diff) | |
download | sos-554c8be31a40ff034cc19d70589cfbc9ee8e9def.tar.gz |
[ceph] Accommodate both running on host and containers
Simplify the log collection condition by introducing a file glob. It can
capture logs from both existing clusters such as package based
deployments and container based deployments such as cephadm.
Closes: #3100
Co-authored-by: Samuel Walladge <samuel.walladge@canonical.com>
Signed-off-by: Nobuto Murata <nobuto.murata@canonical.com>
-rw-r--r-- | sos/report/plugins/ceph_mgr.py | 43 | ||||
-rw-r--r-- | sos/report/plugins/ceph_mon.py | 22 | ||||
-rw-r--r-- | sos/report/plugins/ceph_osd.py | 39 |
3 files changed, 22 insertions, 82 deletions
diff --git a/sos/report/plugins/ceph_mgr.py b/sos/report/plugins/ceph_mgr.py index a7391f96..266be3a2 100644 --- a/sos/report/plugins/ceph_mgr.py +++ b/sos/report/plugins/ceph_mgr.py @@ -35,38 +35,26 @@ class CephMGR(Plugin, RedHatPlugin, UbuntuPlugin): def setup(self): - self.ceph_version = self.get_ceph_version() - - logdir = '/var/log/ceph' - libdir = '/var/lib/ceph' - rundir = '/run/ceph' - - if self.ceph_version >= 16: - logdir += '/*' - libdir += '/*' - rundir += '/*' - self.add_file_tags({ - f'{logdir}/ceph-mgr.*.log': 'ceph_mgr_log', + '/var/log/ceph/(.*/)?ceph-mgr.*.log': 'ceph_mgr_log', }) self.add_forbidden_path([ "/etc/ceph/*keyring*", - f"{libdir}/*keyring*", - f"{libdir}/**/*keyring*", - f"{libdir}/osd*", - f"{libdir}/mon*", + "/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. - f"{libdir}/tmp/*mnt*", + "/var/lib/ceph/**/tmp/*mnt*", "/etc/ceph/*bindpass*", ]) self.add_copy_spec([ - f"{logdir}/ceph-mgr*.log", - f"{libdir}/mgr*", - f"{libdir}/bootstrap-mgr/", - f"{rundir}/ceph-mgr*", + "/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 @@ -104,19 +92,6 @@ class CephMGR(Plugin, RedHatPlugin, UbuntuPlugin): f"ceph daemon {m} {cmd}" for m in self.get_socks() for cmd in cmds] ) - def get_ceph_version(self): - ver = self.exec_cmd('ceph --version') - if ver['status'] == 0: - try: - _ver = ver['output'].split()[2] - return int(_ver.split('.')[0]) - except Exception as err: - self._log_debug(f"Could not determine ceph version: {err}") - self._log_error( - 'Failed to find ceph version, command collection will be limited' - ) - return 0 - def get_socks(self): """ Find any available admin sockets under /var/run/ceph (or subdirs for diff --git a/sos/report/plugins/ceph_mon.py b/sos/report/plugins/ceph_mon.py index f281dc6d..5b248d8a 100644 --- a/sos/report/plugins/ceph_mon.py +++ b/sos/report/plugins/ceph_mon.py @@ -44,34 +44,24 @@ class CephMON(Plugin, RedHatPlugin, UbuntuPlugin): self.ceph_version = self.get_ceph_version() - logdir = '/var/log/ceph' - libdir = '/var/lib/ceph' - rundir = '/run/ceph' - - if self.ceph_version >= 16: - logdir += '/*' - libdir += '/*' - rundir += '/*' - self.add_file_tags({ '.*/ceph.conf': 'ceph_conf', - f"{logdir}/ceph-.*mon.*.log": 'ceph_mon_log' + "/var/log/ceph/(.*/)?ceph-.*mon.*.log": 'ceph_mon_log' }) self.add_forbidden_path([ "/etc/ceph/*keyring*", - f"{libdir}/*keyring*", - f"{libdir}/**/*keyring*", + "/var/lib/ceph/**/*keyring*", # Excludes temporary ceph-osd mount location like # /var/lib/ceph/tmp/mnt.XXXX from sos collection. - f"{libdir}/tmp/*mnt*", + "/var/lib/ceph/**/tmp/*mnt*", "/etc/ceph/*bindpass*" ]) self.add_copy_spec([ - f"{rundir}/ceph-mon*", - f"{libdir}/**/kv_backend", - f"{logdir}/*ceph-mon*.log" + "/run/ceph/**/ceph-mon*", + "/var/lib/ceph/**/kv_backend", + "/var/log/ceph/**/*ceph-mon*.log" ]) self.add_cmd_output([ diff --git a/sos/report/plugins/ceph_osd.py b/sos/report/plugins/ceph_osd.py index 37109125..4ed4565b 100644 --- a/sos/report/plugins/ceph_osd.py +++ b/sos/report/plugins/ceph_osd.py @@ -35,37 +35,25 @@ class CephOSD(Plugin, RedHatPlugin, UbuntuPlugin): def setup(self): - self.ceph_version = self.get_ceph_version() - - logdir = '/var/log/ceph' - libdir = '/var/lib/ceph' - rundir = '/run/ceph' - - if self.ceph_version >= 16: - logdir += '/*' - libdir += '/*' - rundir += '/*' - self.add_file_tags({ - f"{logdir}/ceph-(.*-)?osd.*.log": 'ceph_osd_log', + "/var/log/ceph/(.*/)?ceph-(.*-)?osd.*.log": 'ceph_osd_log', }) self.add_forbidden_path([ "/etc/ceph/*keyring*", - f"{libdir}/*keyring*", - f"{libdir}/**/*keyring*", + "/var/lib/ceph/**/*keyring*", # Excludes temporary ceph-osd mount location like # /var/lib/ceph/tmp/mnt.XXXX from sos collection. - f"{libdir}/tmp/*mnt*", + "/var/lib/ceph/**/tmp/*mnt*", "/etc/ceph/*bindpass*" ]) # Only collect OSD specific files self.add_copy_spec([ - f"{rundir}/ceph-osd*", - f"{libdir}/**/kv_backend", - f"{logdir}/ceph-osd*.log", - f"{logdir}/ceph-volume*.log", + "/run/ceph/**/ceph-osd*", + "/var/lib/ceph/**/kv_backend", + "/var/log/ceph/**/ceph-osd*.log", + "/var/log/ceph/**/ceph-volume*.log", ]) self.add_cmd_output([ @@ -112,17 +100,4 @@ class CephOSD(Plugin, RedHatPlugin, UbuntuPlugin): ceph_sockets.append(self.path_join(rdir, file)) return ceph_sockets - def get_ceph_version(self): - ver = self.exec_cmd('ceph --version') - if ver['status'] == 0: - try: - _ver = ver['output'].split()[2] - return int(_ver.split('.')[0]) - except Exception as err: - self._log_debug(f"Could not determine ceph version: {err}") - self._log_error( - 'Failed to find ceph version, command collection will be limited' - ) - return 0 - # vim: set et ts=4 sw=4 : |