diff options
author | Luca Deri <deri@ntop.org> | 2019-12-01 22:27:26 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2019-12-01 22:27:26 +0100 |
commit | fbc59c5f81cfbf38de063e8afe21e2fa23cc2ad7 (patch) | |
tree | 2f209ac7d509d7f5b288a37bba1b9fd544e7820a /python/flow_printer.py | |
parent | 32dc9e3225cc3c55f263221e8fd723aa85a991af (diff) | |
parent | b4468239b9f55b95b469ee5b394bc647b03645da (diff) |
Merge branch 'dev' of https://github.com/ntop/nDPI into dev
Diffstat (limited to 'python/flow_printer.py')
-rw-r--r-- | python/flow_printer.py | 24 |
1 files changed, 18 insertions, 6 deletions
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 <http://www.gnu.org/licenses/>. """ -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 |