Blame SOURCES/sos-bz1850926-logs-no-journal.patch

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