Skip to content

Commit

Permalink
logs: Use journalctl -o with-unit for default logs
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Aug 30, 2023
1 parent ca8fcd7 commit 85981fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sos/report/plugins/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :

0 comments on commit 85981fe

Please sign in to comment.