sos/sos-bz683219-truncate-large-files.patch
Bryn M. Reeves 13178ca5fa Update sos to 2.2-29
This synchronises sos in master to the current upstream sos-2.2 branch and
includes all patches from RHEL6 not already present.
2012-06-22 12:16:21 +01:00

27 lines
1.1 KiB
Diff

diff -up sos-2.2/sos/plugintools.py.orig sos-2.2/sos/plugintools.py
--- sos-2.2/sos/plugintools.py.orig 2011-08-15 01:33:35.900753944 +0100
+++ sos-2.2/sos/plugintools.py 2011-08-15 01:33:43.762754017 +0100
@@ -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