tab/space issues
This commit is contained in:
parent
97a906435a
commit
0ef3ff79ad
1 changed files with 24 additions and 25 deletions
|
@ -33,28 +33,27 @@ def parse_args(args):
|
||||||
return opts, args
|
return opts, args
|
||||||
|
|
||||||
def search_logs(opts, logfiles):
|
def search_logs(opts, logfiles):
|
||||||
msg = ''
|
msg = ''
|
||||||
for fn in logfiles:
|
for fn in logfiles:
|
||||||
hostname=os.path.basename(fn).replace('.log', '')
|
hostname=os.path.basename(fn).replace('.log', '')
|
||||||
timestamp = os.path.basename(os.path.dirname(fn))
|
timestamp = os.path.basename(os.path.dirname(fn))
|
||||||
for line in open(fn):
|
for line in open(fn):
|
||||||
things = line.split('\t')
|
things = line.split('\t')
|
||||||
if things[2] in opts.search_terms:
|
if things[2] in opts.search_terms:
|
||||||
slurp = json.loads(things[4])
|
slurp = json.loads(things[4])
|
||||||
msg += '%s\t%s\t%s\t%s\t%s\t%s' % (timestamp, hostname, things[0], things[1], things[2], things[3])
|
msg += '%s\t%s\t%s\t%s\t%s\t%s' % (timestamp, hostname, things[0], things[1], things[2], things[3])
|
||||||
if not opts.verbose:
|
if not opts.verbose:
|
||||||
if type(slurp) == dict:
|
if type(slurp) == dict:
|
||||||
for term in ['task_userid', 'cmd']:
|
for term in ['task_userid', 'cmd']:
|
||||||
if term in slurp:
|
if term in slurp:
|
||||||
msg += '\t%s:%s' % (term, slurp.get(term, None))
|
msg += '\t%s:%s' % (term, slurp.get(term, None))
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
else:
|
else:
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
msg += json.dumps(slurp, indent=4)
|
msg += json.dumps(slurp, indent=4)
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
|
|
||||||
return msg
|
|
||||||
|
|
||||||
|
return msg
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue