aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/sos/plugins/sanitize.py12
-rw-r--r--src/lib/sos/plugintools.py23
2 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/sos/plugins/sanitize.py b/src/lib/sos/plugins/sanitize.py
index 421b2314..8d7719d4 100644
--- a/src/lib/sos/plugins/sanitize.py
+++ b/src/lib/sos/plugins/sanitize.py
@@ -15,20 +15,26 @@
import os
import sos.plugintools
import glob
+import socket
class sanitize(sos.plugintools.PluginBase):
""" sanitize plugin
"""
def defaultenabled(self):
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.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") \ No newline at end of file
+ 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")
+
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index cd4864e8..927630bd 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -52,7 +52,7 @@ class PluginBase:
self.alerts = []
self.customText = ""
self.optNames = []
- self.optParms = []
+ self.optParms = []
self.piName = pluginname
self.cInfo = commons
self.forbiddenPaths = []
@@ -109,7 +109,7 @@ class PluginBase:
self.soslog.log(logging.VERBOSE, "problem at path %s (%s)" % (abspath,e))
break
return False
-
+
def doRegexFindAll(self, regex, fname):
''' Return a list of all non overlapping matches in the string(s)
'''
@@ -164,16 +164,16 @@ class PluginBase:
return
except IOError:
self.soslog.log(logging.VERBOSE2, "error copying file %s (IOError)" % (srcpath))
- return
+ return
except:
self.soslog.log(logging.VERBOSE2, "error copying file %s (SOMETHING HAPPENED)" % (srcpath))
- return
+ return
self.copiedFiles.append({'srcpath':srcpath, 'dstpath':tdstpath, 'symlink':"no"}) # save in our list
except (IOError, os.error), why:
self.soslog.log(logging.DEBUG, "skipping symlink creation: (%s)" % (why,))
except shutil.Error, err:
self.soslog.log(logging.DEBUG, "error copying file %s (shutil.Error)" % (srcpath,))
-
+
return
def __copyFile(self, src):
@@ -207,13 +207,13 @@ class PluginBase:
# Glob case handling is such that a valid non-glob is a reduced glob
for filespec in glob.glob(forbiddenPath):
self.forbiddenPaths.append(filespec)
-
+
def getAllOptions(self):
"""
return a list of all options selected
"""
return (self.optNames, self.optParms)
-
+
def setOption(self, optionname, value):
''' set the named option to value.
'''
@@ -374,7 +374,7 @@ class PluginBase:
"""
self.diagnose_msgs.append(alertstring)
return
-
+
# For adding output
def addAlert(self, alertstring):
""" Add an alert to the collection of alerts for this plugin. These
@@ -403,7 +403,7 @@ class PluginBase:
"""
if self.thread: return self.thread.is_alive()
return None
-
+
def wait(self,timeout=None):
"""
wait for a thread to complete - only called for threaded execution
@@ -498,7 +498,7 @@ class PluginBase:
"""This devices whether a plugin should be automatically loaded or
only if manually specified in the command line."""
return True
-
+
def collect(self):
""" This function has been replaced with setup(). Please change your
module calls. Calling setup() now.
@@ -528,7 +528,7 @@ class PluginBase:
perform any postprocessing. To be replaced by a plugin if desired
"""
pass
-
+
def report(self):
""" Present all information that was gathered in an html file that allows browsing
the results.
@@ -584,3 +584,4 @@ class PluginBase:
html = html + self.customText + "</p>\n"
return html
+