diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-01-26 02:34:10 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-01-26 02:34:10 +0100 |
commit | 4bae9d03446b814f3690db3e62dc4156972c2e8c (patch) | |
tree | 456667864b8115fc45bf7f7ce15bdb58b6931de3 /examples/py-flow-dashboard/flow-dash.py | |
parent | 29a1b13e7ac8f20512b7a066c351bad614998f83 (diff) |
py-flow-dashboard: added tab layout and event pie chart
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples/py-flow-dashboard/flow-dash.py')
-rwxr-xr-x | examples/py-flow-dashboard/flow-dash.py | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/examples/py-flow-dashboard/flow-dash.py b/examples/py-flow-dashboard/flow-dash.py index 283a97bb9..e3ac0776d 100755 --- a/examples/py-flow-dashboard/flow-dash.py +++ b/examples/py-flow-dashboard/flow-dash.py @@ -31,7 +31,7 @@ def nDPIsrvd_worker_onFlowCleanup(instance, current_flow, global_user_data): shared_flow_dict['current-guessed-flows'] -= 1 if shared_flow_dict[flow_id]['is_not_detected'] is True: - shared_flow_dict['current-detected-flows'] -= 1 + shared_flow_dict['current-not-detected-flows'] -= 1 if shared_flow_dict[flow_id]['is_midstream'] is True: shared_flow_dict['current-midstream-flows'] -= 1 @@ -49,6 +49,17 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us shared_flow_dict['total-events'] += 1 shared_flow_dict['total-bytes'] = nsock.received_bytes + if 'basic_event_name' in json_dict: + shared_flow_dict['total-base-events'] += 1 + + if 'daemon_event_name' in json_dict: + shared_flow_dict['total-daemon-events'] += 1 + + if 'packet_event_name' in json_dict and \ + (json_dict['packet_event_name'] == 'packet' or \ + json_dict['packet_event_name'] == 'packet-flow'): + shared_flow_dict['total-packet-events'] += 1 + if 'flow_id' not in json_dict: return True else: @@ -56,8 +67,6 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us return False flow_id = current_flow.flow_id - # print(json_dict) - if flow_id not in shared_flow_dict: shared_flow_dict[flow_id] = mgr.dict() shared_flow_dict[flow_id]['is_detected'] = False @@ -86,10 +95,24 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us if json_dict['flow_event_name'] == 'new': - pass + shared_flow_dict['total-flow-new-events'] += 1 + + elif json_dict['flow_event_name'] == 'update': + + shared_flow_dict['total-flow-update-events'] += 1 + + elif json_dict['flow_event_name'] == 'end': + + shared_flow_dict['total-flow-end-events'] += 1 + + elif json_dict['flow_event_name'] == 'idle': + + shared_flow_dict['total-flow-idle-events'] += 1 elif json_dict['flow_event_name'] == 'guessed': + shared_flow_dict['total-flow-guessed-events'] += 1 + if shared_flow_dict[flow_id]['is_guessed'] is False: shared_flow_dict['total-guessed-flows'] += 1 shared_flow_dict['current-guessed-flows'] += 1 @@ -97,6 +120,8 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us elif json_dict['flow_event_name'] == 'not-detected': + shared_flow_dict['total-flow-not-detected-events'] += 1 + if shared_flow_dict[flow_id]['is_not_detected'] is False: shared_flow_dict['total-not-detected-flows'] += 1 shared_flow_dict['current-not-detected-flows'] += 1 @@ -105,6 +130,11 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us elif json_dict['flow_event_name'] == 'detected' or \ json_dict['flow_event_name'] == 'detection-update': + if json_dict['flow_event_name'] == 'detection-update': + shared_flow_dict['total-flow-detection-update-events'] += 1 + else: + shared_flow_dict['total-flow-detected-events'] += 1 + if shared_flow_dict[flow_id]['is_detected'] is False: shared_flow_dict['total-detected-flows'] += 1 shared_flow_dict['current-detected-flows'] += 1 @@ -134,6 +164,8 @@ def nDPIsrvd_worker(address, shared_flow_dict): if __name__ == '__main__': argparser = nDPIsrvd.defaultArgumentParser() + argparser.add_argument('--listen-address', type=str, default='127.0.0.1', help='Plotly listen address') + argparser.add_argument('--listen-port', type=str, default=8050, help='Plotly listen port') args = argparser.parse_args() address = nDPIsrvd.validateAddress(args) @@ -141,6 +173,18 @@ if __name__ == '__main__': shared_flow_dict = mgr.dict() shared_flow_dict['total-events'] = 0 + shared_flow_dict['total-flow-new-events'] = 0 + shared_flow_dict['total-flow-update-events'] = 0 + shared_flow_dict['total-flow-end-events'] = 0 + shared_flow_dict['total-flow-idle-events'] = 0 + shared_flow_dict['total-flow-detected-events'] = 0 + shared_flow_dict['total-flow-detection-update-events'] = 0 + shared_flow_dict['total-flow-guessed-events'] = 0 + shared_flow_dict['total-flow-not-detected-events'] = 0 + shared_flow_dict['total-packet-events'] = 0 + shared_flow_dict['total-base-events'] = 0 + shared_flow_dict['total-daemon-events'] = 0 + shared_flow_dict['total-bytes'] = 0 shared_flow_dict['total-flows'] = 0 shared_flow_dict['total-detected-flows'] = 0 @@ -161,7 +205,7 @@ if __name__ == '__main__': nDPIsrvd_job.start() web_job = multiprocessing.Process(target=plotly_dash.web_worker, - args=(shared_flow_dict,)) + args=(shared_flow_dict, args.listen_address, args.listen_port)) web_job.start() nDPIsrvd_job.join() |