From d3eebcba24d20eb61ee350e385f126e9079dead7 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Tue, 7 Jul 2020 18:59:34 +0200
Subject: [PATCH] [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.
Relevant to: #2130
Resolves: #2142
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/plugins/logs.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py
index 1f0f163..454e847 100644
--- a/sos/plugins/logs.py
+++ b/sos/plugins/logs.py
@@ -57,13 +57,21 @@ class Logs(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
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([
--
1.8.3.1