diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2020-07-07 18:57:15 +0200 |
---|---|---|
committer | Pavel Moravec <pmoravec@redhat.com> | 2020-07-07 18:57:15 +0200 |
commit | 8c2b07adeebed573306bc52a26b37b6def75a925 (patch) | |
tree | 3015678f0031d585551e944fd080a65ad0f2baa9 | |
parent | 001a220f9558929dc1b84bc51930899f651abc36 (diff) | |
download | sos-8c2b07adeebed573306bc52a26b37b6def75a925.tar.gz |
[logs] collect also non-persistent journal logs
Collect journalctl logs also when journal is configured to store logs
in memory only.
Further, apply --since option to journal catalog logs.
Further, when --all-logs is provided, collect the transient logs in
/var/log/journal dir as well.
Resolves: #2130
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r-- | sos/report/plugins/logs.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sos/report/plugins/logs.py b/sos/report/plugins/logs.py index c92cc1f0..e3b6b884 100644 --- a/sos/report/plugins/logs.py +++ b/sos/report/plugins/logs.py @@ -59,13 +59,21 @@ class Logs(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin): self.add_cmd_output("journalctl --disk-usage") self.add_cmd_output('ls -alRh /var/log/') - journal = os.path.exists("/var/log/journal/") - if journal and self.is_installed("systemd"): + # collect journal logs if: + # - there is some data present, either persistent or runtime only + # - systemd-journald service exists + # otherwise fallback to collecting few well known logfiles directly + journal = any([os.path.exists(p + "/log/journal/") + for p in ["/var", "/run"]]) + if journal and self.is_service("systemd-journald"): self.add_journal(since=since) - self.add_journal(boot="this", catalog=True) - self.add_journal(boot="last", catalog=True) + self.add_journal(boot="this", catalog=True, since=since) + self.add_journal(boot="last", catalog=True, since=since) if self.get_option("all_logs"): - self.add_copy_spec("/var/log/journal/*") + self.add_copy_spec([ + "/var/log/journal/*", + "/run/log/journal/*" + ]) else: # If not using journal if not self.get_option("all_logs"): self.add_copy_spec([ |