From 684b5bd93e7a26dc79e9c7129770f8ea10c39361 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 30 Aug 2023 10:45:54 -0400 Subject: [PATCH] logs: Use journalctl -o with-unit for default logs Before systemd was created, syslog was the dominant Unix logging system. Later, systemd introduced the journal whose output intentionally exactly matched that of syslog for compatibility. In systemd, the "unit" is the technical heart of things; yet the syslog output only includes the "syslog identifier" which might or might not look like the unit. For many units that just run shell script, the syslog identifier is just "bash" which is not useful. The `-o with-unit` is in RHEL8 and above; it's not in RHEL7. I don't know if it is a goal of this project to ship the latest releases on very old operating systems. If it is, we can try to do dynamic detection. --- sos/report/plugins/logs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sos/report/plugins/logs.py b/sos/report/plugins/logs.py index 8414503fa5..57446650c2 100644 --- a/sos/report/plugins/logs.py +++ b/sos/report/plugins/logs.py @@ -130,6 +130,10 @@ def setup(self): self.add_cmd_output("journalctl -o export") else: days = self.get_option("log_days", 3) - self.add_journal(since="-%ddays" % days) + # The default journal output is syslog-compatible, but it's much + # more useful to have the systemd unit. Related prior art: + # https://github.com/openshift/installer/pull/7371/commits/948df48aada21e47e9bb0d0a53366871aa21b40a + # https://github.com/coreos/coreos-assembler/commit/c931fe0e9aa6b7c20c8279fdce3b6ef448eac8b8 + self.add_journal(since="-%ddays" % days, output="with-unit") # vim: set et ts=4 sw=4 :