summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/c-captured/c-captured.c14
-rw-r--r--examples/c-collectd/c-collectd.c7
-rwxr-xr-xexamples/py-flow-dashboard/flow-dash.py5
-rwxr-xr-xexamples/py-flow-info/flow-info.py12
4 files changed, 21 insertions, 17 deletions
diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c
index d87fb0df5..443762ced 100644
--- a/examples/c-captured/c-captured.c
+++ b/examples/c-captured/c-captured.c
@@ -397,9 +397,17 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
if (flow_event_name != NULL)
{
- perror_ull(TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_tot_l4_payload_len"),
- &flow_user->flow_tot_l4_payload_len),
- "flow_tot_l4_payload_len");
+ nDPIsrvd_ull nmb = 0;
+
+ perror_ull(TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_src_tot_l4_payload_len"), &nmb),
+ "flow_src_tot_l4_payload_len");
+ flow_user->flow_tot_l4_payload_len += nmb;
+
+ nmb = 0;
+
+ perror_ull(TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_dst_tot_l4_payload_len"), &nmb),
+ "flow_dst_tot_l4_payload_len");
+ flow_user->flow_tot_l4_payload_len += nmb;
}
if (TOKEN_VALUE_EQUALS_SZ(flow_event_name, "new") != 0)
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c
index b4c83d795..e46a50508 100644
--- a/examples/c-collectd/c-collectd.c
+++ b/examples/c-collectd/c-collectd.c
@@ -424,11 +424,12 @@ static int mainloop(int epollfd, struct nDPIsrvd_socket * const sock)
static uint64_t get_total_flow_bytes(struct nDPIsrvd_socket * const sock)
{
- nDPIsrvd_ull total_bytes_ull = 0;
+ nDPIsrvd_ull total_bytes_ull[2] = {0, 0};
- if (TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_tot_l4_payload_len"), &total_bytes_ull) == CONVERSION_OK)
+ if (TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_src_tot_l4_payload_len"), &total_bytes_ull[0]) == CONVERSION_OK &&
+ TOKEN_VALUE_TO_ULL(TOKEN_GET_SZ(sock, "flow_dst_tot_l4_payload_len"), &total_bytes_ull[1]) == CONVERSION_OK)
{
- return total_bytes_ull;
+ return total_bytes_ull[0] + total_bytes_ull[1];
}
else
{
diff --git a/examples/py-flow-dashboard/flow-dash.py b/examples/py-flow-dashboard/flow-dash.py
index 2ac825cac..f2135735d 100755
--- a/examples/py-flow-dashboard/flow-dash.py
+++ b/examples/py-flow-dashboard/flow-dash.py
@@ -96,8 +96,9 @@ def nDPIsrvd_worker_onJsonLineRecvd(json_dict, instance, current_flow, global_us
if current_flow.flow_key != flow_key:
return False
- if 'flow_tot_l4_payload_len' in json_dict:
- shared_flow_dict[flow_key]['total-l4-bytes'] = json_dict['flow_tot_l4_payload_len']
+ if 'flow_src_tot_l4_payload_len' in json_dict and 'flow_dst_tot_l4_payload_len' in json_dict:
+ shared_flow_dict[flow_key]['total-l4-bytes'] = json_dict['flow_src_tot_l4_payload_len'] + \
+ json_dict['flow_dst_tot_l4_payload_len']
if 'midstream' in json_dict and json_dict['midstream'] != 0:
if shared_flow_dict[flow_key]['is_midstream'] is False:
diff --git a/examples/py-flow-info/flow-info.py b/examples/py-flow-info/flow-info.py
index 9a82b9f8b..d341f6c26 100755
--- a/examples/py-flow-info/flow-info.py
+++ b/examples/py-flow-info/flow-info.py
@@ -36,7 +36,6 @@ class Stats:
self.last_status_length = 0
self.avg_xfer_json_bytes = 0.0
self.expired_tot_l4_payload_len = 0
- self.expired_avg_l4_payload_len = 0
self.total_flows = 0
self.risky_flows = 0
self.midstream_flows = 0
@@ -64,7 +63,6 @@ class Stats:
return
set_attr_from_dict(current_flow, json_dict, 'flow_tot_l4_payload_len', 0)
- set_attr_from_dict(current_flow, json_dict, 'flow_avg_l4_payload_len', 0)
if 'ndpi' in json_dict:
set_attr_from_dict(current_flow, json_dict['ndpi'], 'flow_risk', {})
else:
@@ -92,7 +90,6 @@ class Stats:
def updateOnCleanup(self, current_flow):
self.total_flows += 1
self.expired_tot_l4_payload_len += current_flow.flow_tot_l4_payload_len
- self.expired_avg_l4_payload_len += current_flow.flow_avg_l4_payload_len
self.risky_flows += 1 if len(current_flow.flow_risk) > 0 else 0
self.midstream_flows += 1 if current_flow.midstream != 0 else 0
self.guessed_flows += 1 if current_flow.guessed != 0 else 0
@@ -103,7 +100,6 @@ class Stats:
source_count = 0
flow_count = 0
flow_tot_l4_payload_len = 0.0
- flow_avg_l4_payload_len = 0.0
risky = 0
midstream = 0
guessed = 0
@@ -119,14 +115,13 @@ class Stats:
current_flow = instances[alias][source].flows[flow_id]
flow_tot_l4_payload_len += current_flow.flow_tot_l4_payload_len
- flow_avg_l4_payload_len += current_flow.flow_avg_l4_payload_len
risky += 1 if len(current_flow.flow_risk) > 0 else 0
midstream += 1 if current_flow.midstream != 0 else 0
guessed += 1 if current_flow.guessed != 0 else 0
not_detected = 1 if current_flow.not_detected != 0 else 0
return alias_count, source_count, flow_count, \
- flow_tot_l4_payload_len, flow_avg_l4_payload_len, \
+ flow_tot_l4_payload_len, \
risky, midstream, guessed, not_detected
@staticmethod
@@ -146,17 +141,16 @@ class Stats:
def printStatus(self):
alias_count, source_count, flow_count, \
- tot_l4_payload_len, avg_l4_payload_len, \
+ tot_l4_payload_len, \
risky, midstream, guessed, not_detected = self.getStatsFromFlowMgr()
- out_str = '\r[n|tot|avg JSONs: {}|{}|{}/s] [tot|avg l4: {}|{}] ' \
+ out_str = '\r[n|tot|avg JSONs: {}|{}|{}/s] [tot l4: {}] ' \
'[lss|srcs: {}|{}] ' \
'[flws|rsky|mdstrm|!dtctd|gssd: {}|{}|{}|{}|{} / {}|{}|{}|{}|{}] [{}]' \
''.format(self.json_lines,
Stats.prettifyBytes(self.nsock.received_bytes),
Stats.prettifyBytes(self.avg_xfer_json_bytes),
Stats.prettifyBytes(tot_l4_payload_len + self.expired_tot_l4_payload_len),
- Stats.prettifyBytes(avg_l4_payload_len + self.expired_avg_l4_payload_len),
alias_count, source_count,
flow_count, risky, midstream, not_detected, guessed,
flow_count + self.total_flows,