Skip to content

Commit 4bae627

Browse files
committed
Netflow bot: use netflow_flows2 (TimescaleDB)
1 parent 75a2804 commit 4bae627

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

netflowbot.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _get_last_used_ts(job_id):
6464

6565
def _get_current_max_ts():
6666
with get_db_cursor() as c:
67-
c.execute(f"SELECT MAX(ts) FROM {DB_PREFIX}flows;")
67+
c.execute(f"SELECT MAX(ts) FROM {DB_PREFIX}flows2;")
6868
rec = c.fetchone()
6969
if rec is None:
7070
return None
@@ -276,7 +276,7 @@ def get_traffic_for_entity(interval_label, last_used_ts, max_ts, time_between, d
276276
f.{'input_snmp' if direction == DIRECTION_INGRESS else 'output_snmp'},
277277
sum(f.in_bytes)
278278
FROM
279-
{DB_PREFIX}flows "f"
279+
{DB_PREFIX}flows2 "f"
280280
WHERE
281281
f.client_ip = %s AND
282282
f.ts > %s AND
@@ -322,7 +322,7 @@ def get_top_N_IPs_for_entity_interfaces(interval_label, last_used_ts, max_ts, ti
322322
SELECT
323323
distinct(f.{'input_snmp' if direction == DIRECTION_INGRESS else 'output_snmp'}) "interface_index"
324324
FROM
325-
{DB_PREFIX}flows "f"
325+
{DB_PREFIX}flows2 "f"
326326
WHERE
327327
f.client_ip = %s AND
328328
f.ts > %s AND
@@ -336,7 +336,7 @@ def get_top_N_IPs_for_entity_interfaces(interval_label, last_used_ts, max_ts, ti
336336
f.{'ipvX_src_addr' if direction == DIRECTION_INGRESS else 'ipvX_dst_addr'},
337337
sum(f.in_bytes) "traffic"
338338
FROM
339-
{DB_PREFIX}flows "f"
339+
{DB_PREFIX}flows2 "f"
340340
WHERE
341341
f.client_ip = %s AND
342342
f.ts > %s AND
@@ -370,7 +370,7 @@ def get_top_N_IPs_for_entity(interval_label, last_used_ts, max_ts, time_between,
370370
f.{'ipvX_src_addr' if direction == DIRECTION_INGRESS else 'ipvX_dst_addr'},
371371
sum(f.in_bytes) "traffic"
372372
FROM
373-
{DB_PREFIX}flows "f"
373+
{DB_PREFIX}flows2 "f"
374374
WHERE
375375
f.client_ip = %s AND
376376
f.ts > %s AND
@@ -404,7 +404,7 @@ def get_top_N_protocols_for_entity_interfaces(interval_label, last_used_ts, max_
404404
SELECT
405405
distinct(f.{'input_snmp' if direction == DIRECTION_INGRESS else 'output_snmp'}) "interface_index"
406406
FROM
407-
{DB_PREFIX}flows "f"
407+
{DB_PREFIX}flows2 "f"
408408
WHERE
409409
f.client_ip = %s AND
410410
f.ts > %s AND
@@ -418,7 +418,7 @@ def get_top_N_protocols_for_entity_interfaces(interval_label, last_used_ts, max_
418418
f.protocol,
419419
sum(f.in_bytes) "traffic"
420420
FROM
421-
{DB_PREFIX}flows "f"
421+
{DB_PREFIX}flows2 "f"
422422
WHERE
423423
f.client_ip = %s AND
424424
f.ts > %s AND
@@ -453,7 +453,7 @@ def get_top_N_protocols_for_entity(interval_label, last_used_ts, max_ts, time_be
453453
f.protocol,
454454
sum(f.in_bytes) "traffic"
455455
FROM
456-
{DB_PREFIX}flows "f"
456+
{DB_PREFIX}flows2 "f"
457457
WHERE
458458
f.client_ip = %s AND
459459
f.ts > %s AND
@@ -487,7 +487,7 @@ def get_top_N_connections_for_entity(interval_label, last_used_ts, max_ts, time_
487487
f.ipvX_src_addr, f.ipvX_dst_addr,
488488
sum(f.in_bytes) "traffic"
489489
FROM
490-
{DB_PREFIX}flows "f"
490+
{DB_PREFIX}flows2 "f"
491491
WHERE
492492
f.client_ip = %s AND
493493
f.ts > %s AND
@@ -520,7 +520,7 @@ def get_top_N_connections_for_entity(interval_label, last_used_ts, max_ts, time_
520520
# f.PROTOCOL,
521521
# sum(f.IN_BYTES) "traffic"
522522
# FROM
523-
# {DB_PREFIX}flows "f"
523+
# {DB_PREFIX}flows2 "f"
524524
# WHERE
525525
# f.ts >= %s AND
526526
# f.ts < %s AND

0 commit comments

Comments
 (0)