From 6b4a21d613b215c9c6a7575360cc4939ba215d59 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 9 Oct 2018 09:37:25 -0400 Subject: [PATCH] Add log option to collate for per node logs --- confluent_client/bin/collate | 10 +++++++++- confluent_client/doc/man/collate.ronn | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/confluent_client/bin/collate b/confluent_client/bin/collate index 2a629ac2..9a865340 100755 --- a/confluent_client/bin/collate +++ b/confluent_client/bin/collate @@ -48,6 +48,8 @@ argparser.add_option('-c', '--count', action='store_true', argparser.add_option('-r', '--reverse', action='store_true', help='Reverse sort order to show biggest output group ' 'last') +argparser.add_option('-l', '--log', action='store', type='string', dest='log', + help='Log each output to file, using {node} as a placeholder for node.') (options, args) = argparser.parse_args() if sys.stdin.isatty(): argparser.print_help() @@ -64,7 +66,7 @@ def print_current(): if options.diff: grouped.print_deviants(skipmodal=options.skipcommon, count=options.count, reverse=options.reverse) - else: + else options.log: grouped.print_all(skipmodal=options.skipcommon, count=options.count, reverse=options.reverse) @@ -80,6 +82,12 @@ while fullline: continue if ': ' not in line: line = 'UNKNOWN: ' + line + if options.log: + node, output = line.split(': ', 1) + currlog = options.log.format(node=node, nodename=node) + with open(currlog, mode='a') as log: + log.write(output + '\n') + continue grouped.add_line(*line.split(': ', 1)) if options.watch: if not holdoff: diff --git a/confluent_client/doc/man/collate.ronn b/confluent_client/doc/man/collate.ronn index 4f8c48b8..ee0e24a1 100644 --- a/confluent_client/doc/man/collate.ronn +++ b/confluent_client/doc/man/collate.ronn @@ -3,7 +3,7 @@ collate(1) -- Organize text input by node ## SYNOPSIS -` | collate [-a] [-d] [-w] [-s] [-c] [-r]` +` | collate [-a] [-d] [-w] [-s] [-c] [-r] [-l lognametemplate]` ## DESCRIPTION @@ -26,6 +26,10 @@ node and group names sorted alphanumerically. Express all but the most common result group in terms of diff from the most common result group +* `-l`, `--log`: + Save output per node to individual log files, replacing {node} in the name + with the nodename of each + * `-w`, `--watch`: Update results dynamically as data becomes available, rather than waiting for the command to fully complete. @@ -85,4 +89,4 @@ node and group names sorted alphanumerically. ` Processors.ExecuteDisableBit=Enable` - \ No newline at end of file +