From 2d4ab4c925d8283b3e04846e9e4bd8da1783031a Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 21 Jun 2018 20:02:00 +0100 Subject: [logs] fix RedHatLogs syslog/journal handling Fix the detection of syslog logs in RedHatLogs.setup() by storing the absolute path ("/var/log/messages"), and using this to detect the presence of the path with os.path.exists() and append the "*" in-place when making the add_copy_spec() call. Also improve the readability of the method and use an explicit variable, "have_messages", to indicate pressence of syslog style logs. Resolves: #1312 Signed-off-by: Bryn M. Reeves --- sos/plugins/logs.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py index 956faf67..58851f47 100644 --- a/sos/plugins/logs.py +++ b/sos/plugins/logs.py @@ -82,15 +82,17 @@ class RedHatLogs(Logs, RedHatPlugin): # paths for the RedHatLogs plugin do not obey the normal --all-logs # convention. The rotated copies are collected unconditionally # due to their frequent importance in diagnosing problems. - messages = "/var/log/messages*" - secure = "/var/log/secure*" + messages = "/var/log/messages" + secure = "/var/log/secure" - self.add_copy_spec(secure, sizelimit=self.limit) - self.add_copy_spec(messages, sizelimit=self.limit) + have_messages = os.path.exists(messages) + + self.add_copy_spec(secure + "*", sizelimit=self.limit) + self.add_copy_spec(messages + "*", sizelimit=self.limit) # collect three days worth of logs by default if the system is # configured to use the journal and not /var/log/messages - if not os.path.exists(messages) and self.is_installed("systemd"): + if not have_messages and self.is_installed("systemd"): try: days = int(self.get_option("log_days")) except ValueError: -- cgit