aboutsummaryrefslogtreecommitdiff
path: root/python/flow_printer.py
diff options
context:
space:
mode:
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