diff options
author | jwbernin <jwbernin@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2006-08-09 19:00:10 +0000 |
---|---|---|
committer | jwbernin <jwbernin@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2006-08-09 19:00:10 +0000 |
commit | 4204e263be95fda641f41db5242760b28a71b405 (patch) | |
tree | 41cadf580f065c2ff3e343e0ed9f12f042a76c16 | |
parent | 358e5ba36c8b17745d96790cb125eb2160817387 (diff) | |
download | sos-4204e263be95fda641f41db5242760b28a71b405.tar.gz |
Adding option to use multithreading for collection - default is single-threaded
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@37 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r-- | src/lib/sos/plugintools.py | 8 | ||||
-rwxr-xr-x | src/sosreport | 25 |
2 files changed, 23 insertions, 10 deletions
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index d67f17a4..c09fc801 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -267,14 +267,14 @@ class PluginBase: self.customText = self.customText + text return - def doCollect(self): - self.thread = Thread(target=self.copyStuff,name=self.piName+'-thread') + def doCollect(self, verbosity): + self.thread = Thread(target=self.copyStuff,name=self.piName+'-thread',args=(verbosity,)) self.thread.start() def wait(self): self.thread.join() - def copyStuff(self): + def copyStuff(self, verbosity): for path in self.copyPaths: try: self.doCopyFileOrDir(path) @@ -301,7 +301,7 @@ class PluginBase: """ pass - def analyze(self): + def analyze(self, verbosity): pass def postproc(self, dstroot): diff --git a/src/sosreport b/src/sosreport index 5aa7063f..0b4a2787 100755 --- a/src/sosreport +++ b/src/sosreport @@ -41,7 +41,8 @@ cmdParser.add_option("-a","--alloptions",action="store_true",dest="alloptions",d cmdParser.add_option("-f","--fastoptions",action="store_true",dest="fastoptions",default=False,help="Use only fast options for loaded plugins") cmdParser.add_option("-l","--list-plugins",action="store_true",dest="listPlugins",default=False,help="list existing plugins") cmdParser.add_option("-n","--noplugin",action="append",dest="noplugins",help="list of plugin _not_ to load") - +cmdParser.add_option("-v","--verbose",action="count",dest="verbosity",help="How obnoxious we're being about telling the user what we're doing.") +cmdParser.add_option("-m","--multithreaded",action="store_true",dest="multithread",help="Use the multithreaded information gathering mode to speed up the report") (cmdLineOpts,cmdLineArgs)=cmdParser.parse_args() #print cmdLineOpts @@ -184,7 +185,8 @@ def sosreport(): # First, gather and process options for plugname, plug in loadedplugins: - #print "processing options from plugin: %s" % plugname + if cmdLineOpts.verbosity > 3: + print "processing options from plugin: %s" % plugname try: len(cmdLineOpts.noplugins) if plugname not in cmdLineOpts.noplugins: @@ -210,19 +212,30 @@ def sosreport(): # Call the setup method for each plugin for plugname, plug in loadedplugins: + if cmdLineOpts.verbosity > 1: + print "Setting up plugin module %s" % plugname, plug.setup() # Call the collect method for each plugin for plugname, plug in loadedplugins: - plug.doCollect() - - # Wait for all the collcetion threads to exit + if cmdLineOpts.verbosity > 0: + print "Executing plugin %s" % plugname, + if cmdLineOpts.multithread: + plug.doCollect(cmdLineOptions.verbosity) + else: + plug.copyStuff(cmdLineOptions.verbosity) + + # Wait for all the collection threads to exit for plugname, plug in loadedplugins: + if cmdLineOpts.verbosity > 1: + print "Waiting for plugin %s to return" % plugname, plug.wait() # Call the analyze method for each plugin for plugname, plug in loadedplugins: - plug.analyze() + if cmdLineOpts.verbosity > 1: + print "Analyzing results of plugin %s" % plugname, + plug.analyze(cmdLineOpts.verbosity) # Sort the module names to do the report in alphabetical order loadedplugins.sort() |