aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2018-02-16 12:39:46 -0500
committerBryn M. Reeves <bmr@redhat.com>2018-04-30 16:35:51 +0100
commitcee249fe9f3a676841959a6ccd57c44f1f77b693 (patch)
treed2b8c21ca8cb04da3e047805ba0ade6caddf1a09
parent198c94fb85e74b44bdbec791258b8b26a7cb7e47 (diff)
downloadsos-cee249fe9f3a676841959a6ccd57c44f1f77b693.tar.gz
[logs] parse extra rsyslog log configs and include by default
Parse any extra rsyslog configs that are specified via an 'IncludeConfig' line in /etc/rsyslog.conf. Additionally, this makes collection of rsyslog defined log locations a default action, rather than requiring the --all-logs option. Resolves: #1216 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/logs.py34
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(