-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
zeek_pprint.py
32 lines (26 loc) · 1008 Bytes
/
zeek_pprint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""FileTailer Python Class"""
from __future__ import print_function
import os
import sys
import argparse
from pprint import pprint
# Local imports
from zat import bro_log_reader
if __name__ == '__main__':
# Example to run the bro log reader on a given file
# Collect args from the command line
parser = argparse.ArgumentParser()
parser.add_argument('bro_log', type=str, help='Specify a bro log to run BroLogReader test on')
parser.add_argument('-t', '--tail', action='store_true', help='Turn on log tailing')
args, commands = parser.parse_known_args()
# Check for unknown args
if commands:
print('Unrecognized args: %s' % commands)
sys.exit(1)
# File may have a tilde in it
if args.bro_log:
args.bro_log = os.path.expanduser(args.bro_log)
# Run the bro reader on a given log file
reader = bro_log_reader.BroLogReader(args.bro_log, tail=args.tail, strict=True)
for row in reader.readrows():
pprint(row)