diff options
author | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-01-11 20:10:40 +0000 |
---|---|---|
committer | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-01-11 20:10:40 +0000 |
commit | c57c19583fa21ca3dc0d8f388aceb4085e5157c0 (patch) | |
tree | aad511297d6690779796d7559adf5b9ff6c7ea1c /src | |
parent | ad905fbf8c64aab90f76f31e58b0ab28ee1b9cc0 (diff) | |
download | sos-c57c19583fa21ca3dc0d8f388aceb4085e5157c0.tar.gz |
sanitize portions of logfiles
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@674 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/sos/plugins/general.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/lib/sos/plugins/general.py b/src/lib/sos/plugins/general.py index 7458ebea..671a54dc 100644 --- a/src/lib/sos/plugins/general.py +++ b/src/lib/sos/plugins/general.py @@ -15,13 +15,18 @@ import os import sos.plugintools import glob +import commands class general(sos.plugintools.PluginBase): """basic system information """ 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): self.addCopySpec("/etc/redhat-release") @@ -45,14 +50,24 @@ class general(sos.plugintools.PluginBase): self.collectExtOutput("/usr/bin/uptime", root_symlink = "uptime") if self.getOption('all_logs'): - logs=self.doRegexFindAll(r"^\S+\s+(\S+)", "/etc/syslog.conf") - for i in logs: - i = i.lstrip("-") - if not os.path.isfile(i): continue - self.addCopySpec(i) + if self.rhelver == 5 or self.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) return def postproc(self): self.doRegexSub("/etc/sysconfig/rhn/up2date", r"(\s*proxyPassword\s*=\s*)\S+", r"\1***") + + # sanitize ip's, hostnames in logs + if self.getOption('sanitize'): + if self.rhelver == 5 or self.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") return |