aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2011-08-14 09:35:00 +0100
committerBryn M. Reeves <bmr@redhat.com>2011-08-14 09:35:00 +0100
commit1110a96d0461657f133736697cc188b9627911f5 (patch)
tree6aeb0ac83c530ea4c76e5572693daaa7e7e0fca1
parent8528c698719c26c97ae2656a36280b487fb2bef8 (diff)
downloadsos-1110a96d0461657f133736697cc188b9627911f5.tar.gz
Truncate files that exceed specified size limitsos-2.2-11.el6
Resolves: bz683219
-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