diff options
author | Luca Deri <lucaderi@users.noreply.github.com> | 2019-12-01 21:56:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-01 21:56:10 +0100 |
commit | b4468239b9f55b95b469ee5b394bc647b03645da (patch) | |
tree | 140a9f86b432b9a7c6614966d150e801e853ed94 /python/flow_printer.py | |
parent | 95c1282ef478cb2ff624d46a8b0b035de15df33b (diff) | |
parent | a95cfcc98906c1807acf6707c838cc49d15ae39b (diff) |
Merge pull request #814 from aouinizied/python_cffi_bindings
Implement cffi bindings.
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 |