aboutsummaryrefslogtreecommitdiff
path: root/python/flow_printer.py
diff options
context:
space:
mode:
authoraouinizied <aouinizied@gmail.com>2019-11-28 03:09:13 +0100
committeraouinizied <aouinizied@gmail.com>2019-11-28 03:09:13 +0100
commita95cfcc98906c1807acf6707c838cc49d15ae39b (patch)
treebc51e88f8ee4da73100974bbe14717fcbbf98bce /python/flow_printer.py
parentd328c3bccc55d0c0171a3c227a23b8e4e663819d (diff)
Implement cffi bindings.
Diffstat (limited to 'python/flow_printer.py')
-rw-r--r--python/flow_printer.py24
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