aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-06-21 20:02:00 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-21 20:09:52 +0100
commit2d4ab4c925d8283b3e04846e9e4bd8da1783031a (patch)
tree3ace62dfac43a214223bb51b3d19ccfce323be96
parent91d411766d0e315ae97fb5aebdf03865ccdb6e0a (diff)
downloadsos-2d4ab4c925d8283b3e04846e9e4bd8da1783031a.tar.gz
[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 <bmr@redhat.com>
-rw-r--r--sos/plugins/logs.py12
1 files 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: