diff options
-rw-r--r-- | sos/plugins/logs.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/sos/plugins/logs.py b/sos/plugins/logs.py index 477ec3e2..eaa4823e 100644 --- a/sos/plugins/logs.py +++ b/sos/plugins/logs.py @@ -13,6 +13,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os +import glob from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin @@ -39,19 +40,26 @@ class Logs(Plugin): self.add_journal(boot="last", allfields=True, output="verbose") self.add_cmd_output("journalctl --disk-usage") - if self.get_option('all_logs'): - syslog_conf = self.join_sysroot("/etc/syslog.conf") - logs = self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", syslog_conf) - if self.is_installed("rsyslog") \ - or os.path.exists("/etc/rsyslog.conf"): - rsyslog_conf = self.join_sysroot("/etc/rsyslog.conf") - logs += self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", - rsyslog_conf) - for i in logs: - if i.startswith("-"): - i = i[1:] - if os.path.isfile(i): - self.add_copy_spec(i, sizelimit=self.limit) + confs = ['/etc/syslog.conf', '/etc/rsyslog.conf'] + logs = [] + + if os.path.exists('/etc/rsyslog.conf'): + with open('/etc/rsyslog.conf', 'r') as conf: + for line in conf.readlines(): + if line.startswith('$IncludeConfig'): + confs += glob.glob(line.split()[1]) + + for conf in confs: + if not os.path.exists(conf): + continue + config = self.join_sysroot(conf) + logs += self.do_regex_find_all("^\S+\s+(-?\/.*$)\s+", config) + + for i in logs: + if i.startswith("-"): + i = i[1:] + if os.path.isfile(i): + self.add_copy_spec(i, sizelimit=self.limit) def postproc(self): self.do_path_regex_sub( |