aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugins/__init__.py9
-rw-r--r--sos/plugins/general.py54
-rw-r--r--sos/plugins/kernel_rt.py2
-rw-r--r--sos/policies/__init__.py10
-rw-r--r--sos/sosreport.py21
-rw-r--r--sos/utilities.py12
6 files changed, 59 insertions, 49 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 010d404f..beff0acb 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -85,6 +85,7 @@ class Plugin(object):
should not subclass this class directly.
"""
+ plugin_name = None
requires_root = True
version = 'unversioned'
packages = ()
@@ -120,6 +121,8 @@ class Plugin(object):
@classmethod
def name(class_):
"Returns the plugin's name as a string"
+ if class_.plugin_name:
+ return class_.plugin_name
return class_.__name__.lower()
def policy(self):
@@ -750,11 +753,13 @@ class AS7Mixin(object):
self.addStringAsFile(self.query(r), filename=outfile)
-def import_plugin(name):
+def import_plugin(name, superclasses=None):
"""Import name as a module and return a list of all classes defined in that
module"""
try:
plugin_fqname = "sos.plugins.%s" % name
- return import_module(plugin_fqname, superclass=Plugin)
+ if not superclasses:
+ superclasses = (Plugin,)
+ return import_module(plugin_fqname, superclasses)
except ImportError, e:
return None
diff --git a/sos/plugins/general.py b/sos/plugins/general.py
index 1c320e43..1ba95176 100644
--- a/sos/plugins/general.py
+++ b/sos/plugins/general.py
@@ -14,19 +14,17 @@
import os
from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin
-import commands
-class general(Plugin, RedHatPlugin):
- """basic system information
- """
+class general(Plugin):
+ """basic system information"""
+
+ plugin_name = "general"
optionList = [("syslogsize", "max size (MiB) to collect per syslog file", "", 15),
("all_logs", "collect all log files defined in syslog.conf", "", False)]
def setup(self):
self.addCopySpecs([
- "/etc/redhat-release",
- "/etc/fedora-release",
"/etc/init", # upstart
"/etc/event.d", # "
"/etc/inittab",
@@ -52,6 +50,18 @@ class general(Plugin, RedHatPlugin):
self.collectExtOutput("/usr/sbin/alternatives --display java", root_symlink = "java")
self.collectExtOutput("/usr/bin/readlink -f /usr/bin/java")
+
+class RedHatGeneral(general, RedHatPlugin):
+ """Basic system information for RedHat based distributions"""
+
+ def setup(self):
+ super(RedHatGeneral, self).setup()
+
+ self.addCopySpecs([
+ "/etc/redhat-release",
+ "/etc/fedora-release",
+ ])
+
if self.getOption('all_logs'):
rhelver = self.policy().rhelVersion()
logconf = (rhelver in (4, 5)) and "/etc/syslog.conf" \
@@ -62,39 +72,17 @@ class general(Plugin, RedHatPlugin):
self.addCopySpec(i)
def postproc(self):
- self.doRegexSub("/etc/sysconfig/rhn/up2date", r"(\s*proxyPassword\s*=\s*)\S+", r"\1***")
+ self.doRegexSub("/etc/sysconfig/rhn/up2date",
+ r"(\s*proxyPassword\s*=\s*)\S+", r"\1***")
-class generalDebian(Plugin, DebianPlugin, UbuntuPlugin):
+
+class GeneralDebian(general, DebianPlugin, UbuntuPlugin):
"""Basic system information for Debian based distributions"""
- @classmethod
- def name(self):
- return "general"
def setup(self):
+ super(GeneralDebian, self).setup()
self.addCopySpecs([
"/etc/debian_version",
- "/etc/init", # upstart
- "/etc/event.d", # "
- "/etc/inittab",
- "/etc/sos.conf",
- "/etc/sysconfig",
- "/proc/stat",
- "/var/log/dmesg",
- "/var/log/sa",
- "/var/log/pm/suspend.log",
"/var/log/up2date",
- "/etc/hostid",
- "/var/lib/dbus/machine-id",
- "/etc/exports",
"/etc/lsb-release"
])
- self.collectExtOutput("/bin/dmesg", suggest_filename="dmesg_now")
- self.addCopySpecLimit("/var/log/messages*", sizelimit = self.getOption("syslogsize"))
- self.addCopySpecLimit("/var/log/secure*", sizelimit = self.getOption("syslogsize"))
- self.collectExtOutput("/usr/bin/hostid")
- self.collectExtOutput("/bin/hostname", root_symlink = "hostname")
- self.collectExtOutput("/bin/date", root_symlink = "date")
- self.collectExtOutput("/usr/bin/uptime", root_symlink = "uptime")
- self.collectExtOutput("/bin/dmesg")
- self.collectExtOutput("/usr/sbin/alternatives --display java", root_symlink = "java")
- self.collectExtOutput("/usr/bin/readlink -f /usr/bin/java")
diff --git a/sos/plugins/kernel_rt.py b/sos/plugins/kernel_rt.py
index 10f8e57e..da537913 100644
--- a/sos/plugins/kernel_rt.py
+++ b/sos/plugins/kernel_rt.py
@@ -16,7 +16,7 @@
from sos.plugins import Plugin, RedHatPlugin
-class kernel_rt(RedHatPlugin):
+class kernel_rt(Plugin, RedHatPlugin):
'''Information specific to the realtime kernel
'''
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index c4f7010e..80a2ed40 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -127,7 +127,15 @@ No changes will be made to your system.
self.reportName = self.hostname
self.ticketNumber = None
self.package_manager = PackageManager()
- self.valid_subclasses = []
+ self._valid_subclasses = []
+
+ @property
+ def valid_subclasses(self):
+ return [IndependentPlugin] + self._valid_subclasses
+
+ @valid_subclasses.setter
+ def valid_subclasses(self, subclasses):
+ self._valid_subclasses = subclasses
def check(self):
"""
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 63fab633..1fd83efa 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -424,7 +424,8 @@ class SoSReport(object):
for plug in plugins:
plugbase, ext = os.path.splitext(plug)
try:
- plugin_classes = import_plugin(plugbase)
+ plugin_classes = import_plugin(plugbase,
+ tuple(self.policy.valid_subclasses))
for plugin_class in plugin_classes:
if not self.policy.validatePlugin(plugin_class):
@@ -441,14 +442,22 @@ class SoSReport(object):
# plug-in is valid, let's decide whether run it or not
self.plugin_names.append(plugbase)
- if any((self._is_skipped(plugbase),
- self._is_inactive(plugbase, plugin_class),
- self._is_not_default(plugbase, plugin_class),
- self._is_not_specified(plugbase),
- )):
+ if self._is_skipped(plugbase):
+ self._skip(plugin_class, _("skipped"))
+ continue
+
+ if self._is_inactive(plugbase, plugin_class):
self._skip(plugin_class, _("inactive"))
continue
+ if self._is_not_default(plugbase, plugin_class):
+ self._skip(plugin_class, _("not default"))
+ continue
+
+ if self._is_not_specified(plugbase):
+ self._skip(plugin_class, _("not specified"))
+ continue
+
self._load(plugin_class)
except Exception, e:
self.soslog.warning(_("plugin %s does not install, skipping: %s") % (plug, e))
diff --git a/sos/utilities.py b/sos/utilities.py
index e9184394..e705ae7d 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -138,18 +138,18 @@ def sosGetCommandOutput(command, timeout=300):
else:
return (127, "", 0)
-def import_module(module_fqname, superclass=None):
+def import_module(module_fqname, superclasses=None):
"""Imports the module module_fqname and returns a list of defined classes
- from that module. If superclass is defined then the classes returned will
- be subclasses of the specified superclass."""
-
+ from that module. If superclasses is defined then the classes returned will
+ be subclasses of the specified superclass or superclasses. If superclasses
+ is plural it must be a tuple of classes."""
module_name = module_fqname.rpartition(".")[-1]
module = __import__(module_fqname, globals(), locals(), [module_name])
modules = [class_ for cname, class_ in
inspect.getmembers(module, inspect.isclass)
if class_.__module__ == module_fqname]
- if superclass:
- modules = [m for m in modules if issubclass(m, superclass)]
+ if superclasses:
+ modules = [m for m in modules if issubclass(m, superclasses)]
return modules