aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-11-16 17:34:17 +0000
committerpcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-11-16 17:34:17 +0000
commitd341940e3aabaaab618f98cd874ec39c5039c16e (patch)
tree716510f59fa4c8e25281e41bd26a1943c02f66e8
parentbad91c2a9fbcfa28c6f0060e9e551b54f4615597 (diff)
downloadsos-d341940e3aabaaab618f98cd874ec39c5039c16e.tar.gz
Support for tailing logs
When before, no logs were gathered, we now tail the first log file. No point in tailing non-initial log files as they would likely be compressed. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@1006 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r--sos/plugintools.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/sos/plugintools.py b/sos/plugintools.py
index f0c931c1..e1628b80 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
+ if sizelimit and cursize > sizelimit:
+ limit_reached = True
+ break
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), flog[1:] + ".tailed")
def addCopySpec(self, copyspec):
""" Add a file specification (can be file, dir,or shell glob) to be
@@ -377,7 +385,9 @@ class PluginBase:
curdir = os.getcwd()
os.chdir(self.cInfo['dstroot'])
try:
- os.symlink(outfn[len(self.cInfo['dstroot'])+1:], root_symlink.strip("/."))
+ dst_from_root = outfn[len(self.cInfo['dstroot'])+1:]
+ target = ("../" * string.count(dst_from_root, "/")) + dst_from_root
+ os.symlink(target, root_symlink.strip("/."))
except:
pass
os.chdir(curdir)