aboutsummaryrefslogtreecommitdiffstats
path: root/sos/plugins/sanitize.py
diff options
context:
space:
mode:
Diffstat (limited to 'sos/plugins/sanitize.py')
-rw-r--r--sos/plugins/sanitize.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/sos/plugins/sanitize.py b/sos/plugins/sanitize.py
new file mode 100644
index 00000000..00c883ee
--- /dev/null
+++ b/sos/plugins/sanitize.py
@@ -0,0 +1,41 @@
+### This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import os
+import sos.plugintools
+import glob
+import socket
+
+class sanitize(sos.plugintools.PluginBase):
+ """ sanitize specified log files, etc
+ """
+ def defaultenabled(self):
+ # disabled by default b/c still a work in progress
+ return False
+
+ def setup(self):
+ # sanitize ip's, hostnames in logs
+ hostname = socket.gethostname()
+ 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.addCopySpec(log)
+
+ def postproc(self):
+ self.doRegexSub('/var/log/messages', r"^\s+(%s)" % (hostname,), r"\1sanitized-hostname")
+ self.doRegexSub('/var/log/messages', r"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", r"\1sanitized-ip")
+