aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsconklin <sconklin@ef72aa8b-4018-0410-8976-d6e080ef94d8>2006-09-07 19:12:28 +0000
committersconklin <sconklin@ef72aa8b-4018-0410-8976-d6e080ef94d8>2006-09-07 19:12:28 +0000
commit42272212d47a76322e1523985f4306b65cd5745f (patch)
tree16e2f278f5eb3b5f27549bb4741a6bfc92861749
parentbcb932318630eac91f4087758e216d00ed58d271 (diff)
downloadsos-42272212d47a76322e1523985f4306b65cd5745f.tar.gz
Added alerts for tainted kernel and some well-known tainting modules.
Moved verbosity from a parameter to the global info list. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@52 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r--src/lib/sos/plugins/kernel.py53
-rw-r--r--src/lib/sos/plugintools.py7
-rwxr-xr-xsrc/sosreport9
3 files changed, 60 insertions, 9 deletions
diff --git a/src/lib/sos/plugins/kernel.py b/src/lib/sos/plugins/kernel.py
index 56f186c1..9f96a777 100644
--- a/src/lib/sos/plugins/kernel.py
+++ b/src/lib/sos/plugins/kernel.py
@@ -13,17 +13,42 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import sos.plugintools
-import commands, os
+import commands, os, re
class kernel(sos.plugintools.PluginBase):
"""This plugin gathers kernel related information
"""
optionList = [("modinfo", 'Gathers module information on all modules', 'fast', 1),
('sysrq', 'Trigger SysRq dumps', 'fast', 1)]
+ moduleFile = ""
+ taintList = [
+ {'regex':'mvfs*', 'description':'Clearcase module'},
+ {'regex':'vnode*', 'description':'Clearcase module'},
+ {'regex':'vxfs*', 'description':'Veritas file system module'},
+ {'regex':'vxportal*', 'description':'Veritas module'},
+ {'regex':'vxdmp*', 'description':'Veritas dynamic multipathing module'},
+ {'regex':'vxio*', 'description':'Veritas module'},
+ {'regex':'vxspec*"', 'description':'Veritas module'},
+ {'regex':'dcd*', 'description':'Dell OpenManage Server Administrator module'},
+ {'regex':'ocfs', 'description':'Oracle cluster filesystem module'},
+ {'regex':'oracle*', 'description':'Oracle module'},
+ {'regex':'vmnet*', 'description':'VMware module'},
+ {'regex':'vmmon*', 'description':'VMware module'},
+ {'regex':'egenera*', 'description':'Egenera module'},
+ {'regex':'emcp*', 'description':'EMC module'},
+ {'regex':'ocfs*', 'description':'OCFS module'},
+ {'regex':'nvidea', 'description':'nVidea module'},
+ {'regex':'ati-', 'description':'ATI module'}
+ ]
+
+ # HP
+ #
+ #
+
def setup(self):
self.collectExtOutput("/bin/uname -a")
- self.collectExtOutput("/sbin/lsmod")
+ self.moduleFile = self.collectOutputNow("/sbin/lsmod")
if self.isOptionEnabled('modinfo'):
for kmod in commands.getoutput('/sbin/lsmod | /bin/cut -f1 -d" " 2>/dev/null | /bin/grep -v Module 2>/dev/null').split('\n'):
if '' != kmod.strip():
@@ -43,6 +68,7 @@ class kernel(sos.plugintools.PluginBase):
self.collectExtOutput("/usr/sbin/dkms status")
self.addCopySpec("/proc/cmdline")
self.addCopySpec("/proc/driver")
+ self.addCopySpec("/proc/sys/kernel/tainted")
# trigger some sysrq's. I'm not sure I like doing it this way, but
# since we end up with the sysrq dumps in syslog whether we run the
# syslog report before or after this, I suppose I can live with it.
@@ -59,3 +85,26 @@ class kernel(sos.plugintools.PluginBase):
return
+ def analyze(self):
+ savedtaint = os.path.join(self.cInfo['dstroot'], "/proc/sys/kernel/tainted")
+ infd = open(savedtaint, "r")
+ line = infd.read()
+ infd.close()
+ line = line.strip()
+ if (line != "0"):
+ self.addAlert("Kernel taint flag is <%s>\n" % line)
+
+
+ infd = open(self.moduleFile, "r")
+ modules = infd.readlines()
+ infd.close()
+
+ #print(modules)
+ for tainter in self.taintList:
+ p = re.compile(tainter['regex'])
+ for line in modules:
+ if p.match(line) != None:
+ # found a taint match, create an alert
+ moduleName = line.split()[0]
+ self.addAlert("Check for tainted kernel by module %s, which is %s" % (moduleName, tainter['description']))
+ return
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index ac057dba..2ac67eeb 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -299,10 +299,11 @@ class PluginBase:
self.customText = self.customText + text
return
- def doCollect(self, verbosity):
+ def doCollect(self):
"""
create a thread which calls the copyStuff method for a plugin
"""
+ verbosity = self.cInfo['verbosity']
self.thread = Thread(target=self.copyStuff, name=self.piName+'-thread', args=(verbosity,))
self.thread.start()
@@ -312,7 +313,7 @@ class PluginBase:
"""
self.thread.join()
- def copyStuff(self, verbosity):
+ def copyStuff(self):
"""
Collect the data for a plugin
"""
@@ -342,7 +343,7 @@ class PluginBase:
"""
pass
- def analyze(self, verbosity):
+ def analyze(self):
"""
perform any analysis. To be replaced by a plugin if desired
"""
diff --git a/src/sosreport b/src/sosreport
index a842f3ee..998f3653 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -149,7 +149,8 @@ def sosreport():
logfd = open(logdir + "/sos.log", "w")
# set up dict so everyone can share the following
- commons = {'dstroot': dstroot, 'cmddir': cmddir, 'logdir': logdir, 'rptdir': rptdir, 'logfd': logfd, 'policy': policy}
+ commons = {'dstroot': dstroot, 'cmddir': cmddir, 'logdir': logdir, 'rptdir': rptdir,
+ 'logfd': logfd, 'policy': policy, 'verbosity' : __cmdLineOpts__.verbosity}
# validate and load plugins
@@ -226,9 +227,9 @@ def sosreport():
if __cmdLineOpts__.verbosity > 0:
print "Executing plugin %s" % plugname
if __cmdLineOpts__.multithread:
- plug.doCollect(__cmdLineOpts__.verbosity)
+ plug.doCollect()
else:
- plug.copyStuff(__cmdLineOpts__.verbosity)
+ plug.copyStuff()
# Wait for all the collection threads to exit
if __cmdLineOpts__.multithread:
@@ -241,7 +242,7 @@ def sosreport():
for plugname, plug in loadedplugins:
if __cmdLineOpts__.verbosity > 1:
print "Analyzing results of plugin %s" % plugname,
- plug.analyze(__cmdLineOpts__.verbosity)
+ plug.analyze()
# Sort the module names to do the report in alphabetical order
loadedplugins.sort()