Skip to content

Commit 3781e42

Browse files
committed
Fix: unknown protocol should not throw a KeyError exception
1 parent b1f6c9a commit 3781e42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

netflowbot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ def get_top_N_protocols_for_entity(interval_label, last_used_ts, max_ts, time_be
478478

479479
output_path_entity = NetFlowBot.construct_output_path_prefix(interval_label, direction, entity_id, interface=None)
480480
for protocol, traffic_bytes in c.fetchall():
481-
output_path = f"{output_path_entity}.topprotocol.{path_part_encode(PROTOCOLS[protocol])}"
481+
protocol_label = PROTOCOLS[protocol] if protocol in PROTOCOLS else f"proto{protocol}"
482+
output_path = f"{output_path_entity}.topprotocol.{path_part_encode(protocol_label)}"
482483
values.append({
483484
'p': output_path,
484485
'v': traffic_bytes / time_between, # Bps

0 commit comments

Comments
 (0)