aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugintools.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/sos/plugintools.py b/sos/plugintools.py
index f0c931c1..403e25cd 100644
--- a/sos/plugintools.py
+++ b/sos/plugintools.py
@@ -286,11 +286,19 @@ class PluginBase:
files = glob.glob(fname)
files.sort()
cursize = 0
+ limit_reached = False
+ sizelimit *= 1024 * 1024 # in MB
for flog in files:
cursize += os.stat(flog)[ST_SIZE]
- if sizelimit and (cursize / 1024 / 1024) > sizelimit:
- break
- self.addCopySpec(flog)
+ if sizelimit and cursize > sizelimit:
+ limit_reached = True
+ else:
+ self.addCopySpec(flog)
+ # Truncate the first file (others would likely be compressed),
+ # ensuring we get at least some logs
+ if flog == files[0] and limit_reached:
+ self.collectExtOutput("tail -c%d %s" % (sizelimit, flog),
+ "tail_" + os.path.basename(flog))
def addCopySpec(self, copyspec):
""" Add a file specification (can be file, dir,or shell glob) to be