From 09e8e83472f8ef32e419e3542a6bd725f4d49e3d Mon Sep 17 00:00:00 2001 From: astokes Date: Mon, 11 Jan 2010 21:14:30 +0000 Subject: general plugin to sanitize logs finished, fixme: broken copiedfiles list within postproc?!?! git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@675 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/lib/sos/plugins/general.py | 19 ++++++++++--------- src/lib/sos/plugins/system.py | 1 + src/sos.spec | 6 +++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/lib/sos/plugins/general.py b/src/lib/sos/plugins/general.py index 671a54dc..44e81c1a 100644 --- a/src/lib/sos/plugins/general.py +++ b/src/lib/sos/plugins/general.py @@ -22,10 +22,9 @@ class general(sos.plugintools.PluginBase): """ optionList = [("syslogsize", "max size (MiB) to collect per syslog file", "", 15), - ("all_logs", "collect all log files defined in syslog.conf", "", False) + ("all_logs", "collect all log files defined in syslog.conf", "", False), ("sanitize", "scrub hostname/ip's from log files", "", False)] - rhelver = self.policy().rhelVersion() hostname = commands.getoutput("/bin/hostname") def setup(self): @@ -50,11 +49,12 @@ class general(sos.plugintools.PluginBase): self.collectExtOutput("/usr/bin/uptime", root_symlink = "uptime") if self.getOption('all_logs'): - if self.rhelver == 5 or self.rhelver == 4: + rhelver = self.policy().rhelVersion() + if rhelver == 5 or rhelver == 4: logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/syslog.conf") - for i in logs: - if not os.path.isfile(i): continue - self.addCopySpec(i) + for i in logs: + if not os.path.isfile(i): continue + self.addCopySpec(i) return @@ -63,11 +63,12 @@ class general(sos.plugintools.PluginBase): # sanitize ip's, hostnames in logs if self.getOption('sanitize'): - if self.rhelver == 5 or self.rhelver == 4: + rhelver = self.policy().rhelVersion() + if rhelver == 5 or rhelver == 4: logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/syslog.conf") else: logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/rsyslog.conf") for log in logs: - self.doRegexSub(log, r"(\s*%s)\S+" % (self.hostname,), r"\1sanitized-hostname") - self.doRegexSub(log, r"([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\})", r"\1sanitized-ip") + self.doRegexSub(log, r"\s+(%s.*)" % (self.hostname,), r"\1sanitized-hostname") + self.doRegexSub(log, r"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", r"\1sanitized-ip") return diff --git a/src/lib/sos/plugins/system.py b/src/lib/sos/plugins/system.py index 8a19fcd1..82b04604 100644 --- a/src/lib/sos/plugins/system.py +++ b/src/lib/sos/plugins/system.py @@ -24,6 +24,7 @@ class system(sos.plugintools.PluginBase): self.addCopySpec("/var/spool/cron*") self.addCopySpec("/var/log/cron*") self.addCopySpec("/etc/syslog.conf") + self.addCopySpec("/etc/rsyslog.conf") self.addCopySpec("/etc/ntp.conf") self.addCopySpec("/etc/ntp/step-tickers") self.addCopySpec("/etc/ntp/ntpservers") diff --git a/src/sos.spec b/src/sos.spec index 19a64515..96d3169e 100644 --- a/src/sos.spec +++ b/src/sos.spec @@ -3,7 +3,7 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos Version: 1.8 -Release: 20%{?dist} +Release: 21%{?dist} Group: Applications/System Source0: https://fedorahosted.org/releases/s/o/sos/%{name}-%{version}.tar.gz License: GPLv2+ @@ -53,6 +53,10 @@ rm -rf ${RPM_BUILD_ROOT} %config %{_sysconfdir}/sos.conf %changelog +* Mon Jan 11 2010 Adam Stokes = 1.8-21 +- more sanitizing options for log files +- rhbz fixes from RHEL version merged into trunk + * Tue Nov 19 2009 Adam Stokes = 1.8-20 - dont copy unwanted files due to symlinks - More plugin enhancements -- cgit