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