aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/TODO2
-rwxr-xr-xsrc/lib/sos/helpers.py2
-rw-r--r--src/lib/sos/plugintools.py17
-rwxr-xr-xsrc/sosreport38
4 files changed, 36 insertions, 23 deletions
diff --git a/src/TODO b/src/TODO
index 448aa33f..22122193 100644
--- a/src/TODO
+++ b/src/TODO
@@ -1,5 +1,7 @@
To Do List:
+ * Gather statistics (time, files collected, commands run) per plugin
+
* Choose sane defaults to satisfy Red Hat support requirements (ie. what
plugins should be loaded by default, with what options, etc)
diff --git a/src/lib/sos/helpers.py b/src/lib/sos/helpers.py
index 09bb356f..2e553a1f 100755
--- a/src/lib/sos/helpers.py
+++ b/src/lib/sos/helpers.py
@@ -64,7 +64,7 @@ def sosGetCommandOutput(command):
stime = time()
errdata = ''
status,outdata=commands.getstatusoutput(command)
- return (status, ''.join(outdata), time()-stime)
+ return (status, outdata, time()-stime)
# this needs to be made clean and moved to the plugin tools, so
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index b403af4e..1dac3987 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -294,16 +294,21 @@ class PluginBase:
def makeCommandFilename(self, exe):
""" The internal function to build up a filename based on a command """
- # build file name for output
- rawcmd = os.path.basename(exe).strip()
- mangledname = re.sub(r"[^\w-]+", "_", rawcmd)[0:32]
+ mangledname = re.sub(r"[^\w\-\.\/]+", "_", exe)
+ mangledname = re.sub(r"/", ".", mangledname).strip(" ._-")[0:64]
outfn = self.cInfo['cmddir'] + "/" + self.piName + "/" + mangledname
# check for collisions
- while os.path.exists(outfn):
- outfn = outfn + "z"
+ inc = 0
+ if os.path.exists(outfn):
+ inc = 2
+ while True:
+ newfn = outfn + "_" + inc
+ if not os.path.exists(newfn):
+ break
+ inc +=1
return outfn
@@ -328,7 +333,7 @@ class PluginBase:
os.mkdir(os.path.dirname(outfn))
outfd = open(outfn, "w")
- outfd.write(shout)
+ if len(shout): outfd.write(shout+"\n")
outfd.close()
if root_symlink:
diff --git a/src/sosreport b/src/sosreport
index 5858d719..1c9a37c0 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -63,10 +63,8 @@ def doExitCode():
if ( ( activeCount() == 1 ) and ( __breakHits__ > 2 ) ):
print "Multiple SIGTERMs, single thread, exiting without cleaning up."
sys.exit(3)
-
# FIXME: Add code here to clean up /tmp
- print "Calling sys.exit from doExitCode()"
sys.exit("Abnormal exit")
# Handle any sort of exit signal cleanly
@@ -128,9 +126,9 @@ __cmdParser__.add_option("-c", "--curses", action="store_true", \
__cmdParser__.add_option("--no-progressbar", action="store_false", \
dest="progressbar", default=True, \
help="Do not display a progress bar.")
-__cmdParser__.add_option("--no-multithread", action="store_false", \
- dest="multithread", \
- help="Disable multithreaded gathering mode to speed up the report", default=False)
+__cmdParser__.add_option("--no-multithread", action="store_true", \
+ dest="nomultithread", \
+ help="Disable multi-threaded gathering mode (slower)", default=False)
(__cmdLineOpts__, __cmdLineArgs__)=__cmdParser__.parse_args()
def get_curse_options(alloptions):
@@ -188,7 +186,7 @@ def get_curse_options(alloptions):
return out
class progressBar:
- def __init__(self, minValue = 0, maxValue = 10, totalWidth=12):
+ def __init__(self, minValue = 0, maxValue = 10, totalWidth=40):
self.progBar = "[]" # This holds the progress bar string
self.min = minValue
self.max = maxValue
@@ -223,7 +221,10 @@ class progressBar:
ETA = "[%02d:%02d/%02d:%02d]" % (round(timeElapsed/60), timeElapsed % 60, round(ETA/60), ETA % 60)
else:
ETA = "[%02d:%02d/--:--]" % (round(timeElapsed/60), timeElapsed % 60)
- percentDone = 0
+ if self.amount < self.max:
+ percentDone = 0
+ else:
+ percentDone = 100
# Figure out how many hash bars the percentage should be
allFull = self.width - 2
@@ -535,26 +536,31 @@ Press ENTER to continue, or CTRL-C to quit.
# Setup the progress bar
if __cmdLineOpts__.progressbar:
- pbar = progressBar(0, len(loadedplugins), totalWidth = 60)
+ pbar = progressBar(minValue = 0, maxValue = len(loadedplugins))
# Call the setup method for each plugin
for plugname, plug in loadedplugins:
soslog.log(logging.VERBOSE2, "Setting up plugin module %s" % plugname)
plug.setup()
+
if __cmdLineOpts__.progressbar:
- pbar.incAmount()
+ # gather information useful for generating ETA
+ eta_weight = 0
+ for plugname, plug in loadedplugins:
+ eta_weight += plug.eta_weight
+ pbar.max += eta_weight
+ # pbar.max = number_of_plugins + weight (default 1 per plugin)
pbar.update()
- # gather information useful for generating ETA
- eta_weight = 0
- for plugname, plug in loadedplugins:
- eta_weight += plug.eta_weight
- pbar.max = eta_weight
+ if __cmdLineOpts__.nomultithread:
+ soslog.log(logging.VERBOSE, "using single-threading")
+ else:
+ soslog.log(logging.VERBOSE, "using multi-threading")
# Call the collect method for each plugin
for plugname, plug in loadedplugins:
soslog.log(logging.VERBOSE, "Executing plugin %s" % plugname)
- if __cmdLineOpts__.multithread:
+ if not __cmdLineOpts__.nomultithread:
plug.doCollect()
else:
plug.copyStuff()
@@ -563,7 +569,7 @@ Press ENTER to continue, or CTRL-C to quit.
pbar.update()
# Wait for all the collection threads to exit
- if __cmdLineOpts__.multithread:
+ if not __cmdLineOpts__.nomultithread:
finishedplugins = []
while len(loadedplugins) > 0:
plugname, plug = loadedplugins.pop(0)