From a95cfcc98906c1807acf6707c838cc49d15ae39b Mon Sep 17 00:00:00 2001 From: aouinizied Date: Thu, 28 Nov 2019 03:09:13 +0100 Subject: Implement cffi bindings. --- python/flow_printer.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'python/flow_printer.py') diff --git a/python/flow_printer.py b/python/flow_printer.py index a30ea79b9..305500f0f 100644 --- a/python/flow_printer.py +++ b/python/flow_printer.py @@ -17,11 +17,23 @@ You should have received a copy of the GNU General Public License along with nfs If not, see . """ -from nfstream.streamer import Streamer +from nfstream import NFStreamer import sys -flow_streamer = Streamer(source=sys.argv[1]) -flows_count = 0 -for flow in flow_streamer: - print("flow[{}]: \n{}\n".format(flows_count, flow)) - flows_count += 1 + +path = sys.argv[1] +flow_streamer = NFStreamer(source=path) +result = {} +try: + for flow in flow_streamer: + print(flow) + try: + result[flow.application_name] += flow.total_packets + except KeyError: + result[flow.application_name] = flow.total_packets + print("Summary (Application Name: Packets):") + print(result) +except KeyboardInterrupt: + print("Summary (Application Name: Packets):") + print(result) + print("Terminated.") \ No newline at end of file -- cgit v1.2.3