Skip to content

Commit

Permalink
refactor: remove support of iperf
Browse files Browse the repository at this point in the history
This feature has never been really used nor supported.
Netprobify is not the right tool to run iperf.
  • Loading branch information
kpetremann committed Oct 1, 2024
1 parent 85d4f82 commit a046f6c
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 525 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ venv.bak/

# generated by build
coverage-*3*.xml
junit-*3*.xml
junit*.xml
pylama-parent.ini
tox-parent.ini
adapt_template.sh
Expand Down
91 changes: 2 additions & 89 deletions netprobify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
ICMP_LOSS_RATIO,
ICMP_ROUND_TRIP,
ICMP_SENT,
IPERF_BANDWIDTH,
IPERF_LOSS,
IPERF_LOSS_RATIO,
IPERF_OUT_OF_ORDER,
IPERF_SENT,
LIST_TARGET_MEASUREMENT_METRICS,
LIST_TARGET_METRICS,
NETPROBIFY_INFO,
Expand All @@ -62,7 +57,6 @@
)
from netprobify.protocol.common.protocols import list_self_ips
from netprobify.protocol.icmp_ping import ICMPping
from netprobify.protocol.iperf import Iperf
from netprobify.protocol.target import Group
from netprobify.protocol.tcpsyn import TCPsyn
from netprobify.protocol.udp_unreachable import UDPunreachable
Expand Down Expand Up @@ -106,9 +100,7 @@ def __init__(self, f="config.yaml"):
self.config_file = f
self.list_targets = []
self.list_target_name = []
self.list_special_targets = []
self.list_dynamic_targets = []
self.list_dynamic_special_targets = []
self.shared_dynamic_targets = {}
self.shared_dynamic_targets_backup = {}
self.list_groups = []
Expand Down Expand Up @@ -235,42 +227,12 @@ def load_target_conf(self, target, target_name, target_groups):
creation_date=target.get("creation_date"),
lifetime=target.get("lifetime"),
)
elif target["type"] == "iperf":
target = Iperf(
name=target_name,
active=True,
description=target.get("description", target_name),
destination=None,
config_destination=target["destination"],
address_family=target.get("address_family", DEFAULT_ADDRESS_FAMILY),
dst_port=target["dst_port"],
threshold=target.get("threshold"),
state=target.get("state"),
alert_level=target.get("alert_level", "no_alert"),
is_dynamic=target.get("is_dynamic", False),
# dns_update interval is global if not specified
dns_update_interval=target.get(
"dns_update_interval", self.global_vars.get("dns_update_interval", 0)
),
groups=target_groups,
duration=target.get("iperf_parameters", {}).get("duration", 5),
bandwidth=target.get("iperf_parameters", {}).get("bandwidth_per_stream", "1M"),
protocol=target.get("iperf_parameters", {}).get("protocol", "udp"),
num_streams=target.get("iperf_parameters", {}).get("nb_parallel_streams", 1),
creation_date=target.get("creation_date"),
lifetime=target.get("lifetime"),
)
else:
return

# we put the target in the right list
if target.is_dynamic:
if target.is_special:
self.list_dynamic_special_targets.append(target)
else:
self.list_dynamic_targets.append(target)
elif target.is_special:
self.list_special_targets.append(target)
self.list_dynamic_targets.append(target)
else:
self.list_targets.append(target)

Expand All @@ -285,7 +247,6 @@ def load_conf(self, schema_file="schema_config.yaml"):
# cleaning targets list
self.list_groups = []
self.list_targets = []
self.list_special_targets = []
self.list_target_name = []
self.global_vars = {}
self.first_iter = True
Expand Down Expand Up @@ -387,7 +348,7 @@ def load_conf(self, schema_file="schema_config.yaml"):

log.debug("Target %s created", target_name)

if len(target_groups) == 0 and target["type"] != "iperf":
if len(target_groups) == 0:
log.warning("Target %s disabled: not associated to any group", target_name)

def update_hosts(self, force=False):
Expand All @@ -399,9 +360,7 @@ def update_hosts(self, force=False):
self_ips = {af: list_self_ips(af, scapyconf) for af in ("ipv4", "ipv6")}
for target in itertools.chain(
self.list_targets,
self.list_special_targets,
self.list_dynamic_targets,
self.list_dynamic_special_targets,
):
if len(target.groups):
changed = False
Expand Down Expand Up @@ -772,47 +731,6 @@ def get_metrics(self):
destination=name,
address_family=address_family,
).inc(port_mismatch)
elif res["probing_type"] == "iperf":
loss_ratio = res["loss"] / res["sent"] if res["sent"] != 0 else 0
IPERF_SENT.labels(
probe_name=self.global_vars["probe_name"],
destination=name,
address_family=address_family,
state=res["state"],
group=grp.name,
).set(res["sent"])

IPERF_LOSS.labels(
probe_name=self.global_vars["probe_name"],
destination=name,
address_family=address_family,
state=res["state"],
group=grp.name,
).set(res["loss"])

IPERF_LOSS_RATIO.labels(
probe_name=self.global_vars["probe_name"],
destination=name,
address_family=address_family,
state=res["state"],
group=grp.name,
).set(loss_ratio)

IPERF_BANDWIDTH.labels(
probe_name=self.global_vars["probe_name"],
destination=name,
address_family=address_family,
state=res["state"],
group=grp.name,
).set(res["bandwidth"])

IPERF_OUT_OF_ORDER.labels(
probe_name=self.global_vars["probe_name"],
destination=name,
address_family=address_family,
state=res["state"],
group=grp.name,
).set(res["out_of_order"])

def reload_request(self, signum, frame):
"""Reload handler for SIGHUP. Will reload the configuration.
Expand Down Expand Up @@ -879,7 +797,6 @@ def get_dynamic_targets(self):

# we reset the targets
self.list_dynamic_targets = []
self.list_dynamic_special_targets = []

# get targets by inventory
for inventory in self.shared_dynamic_targets.keys():
Expand Down Expand Up @@ -1075,10 +992,6 @@ def main(self):
self.global_vars.get("timeout", 3600),
)

# start probing only for special targets which are not a priority
remaining_time = self.global_vars["interval"] - (time.time() - round_start)
self.start_processes(self.list_special_targets, remaining_time)

# the first iteration is done
self.first_iter = False

Expand Down
32 changes: 0 additions & 32 deletions netprobify/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,6 @@
["probe_name", "destination", "address_family"],
)

# prometheus metrics - iperf probe
IPERF_SENT = Gauge(
"iperf_sent_total",
"number of sent packets reported by iperf.",
["probe_name", "destination", "address_family", "state", "group"],
)
IPERF_LOSS = Gauge(
"iperf_loss_total",
"number of lost packets reported by iperf.",
["probe_name", "destination", "address_family", "state", "group"],
)
IPERF_LOSS_RATIO = Gauge(
"iperf_loss_ratio",
"loss ratio reported by iperf.",
["probe_name", "destination", "address_family", "state", "group"],
)
IPERF_BANDWIDTH = Gauge(
"iperf_bandwidth_bps",
"bandwidth reported by iperf.",
["probe_name", "destination", "address_family", "state", "group"],
)
IPERF_OUT_OF_ORDER = Gauge(
"iperf_out_of_order_count",
"port source/destination mismatch.",
["probe_name", "destination", "address_family", "state", "group"],
)

# prometheus metrics - common
THRESHOLD = Gauge(
"threshold",
Expand Down Expand Up @@ -175,11 +148,6 @@
ICMP_LOSS,
ICMP_ROUND_TRIP,
ICMP_LOSS_RATIO,
IPERF_SENT,
IPERF_LOSS,
IPERF_LOSS_RATIO,
IPERF_BANDWIDTH,
IPERF_OUT_OF_ORDER,
]

LIST_TARGET_METRICS = LIST_TARGET_HEALTH_METRICS + LIST_TARGET_MEASUREMENT_METRICS
142 changes: 0 additions & 142 deletions netprobify/protocol/iperf.py

This file was deleted.

1 change: 0 additions & 1 deletion netprobify/protocol/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def __init__(

self.time_to_refresh = time.time()
self.packets = []
self.is_special = False
self.config_ip_payload_size = ip_payload_size
self.proto_payload_size = None

Expand Down
4 changes: 3 additions & 1 deletion netprobify/protocol/tcpsyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ def send_packets(self, res, logging_level, all_groups, verbose=0, force_raw_sock
if seq_acked not in packets:
log_tcpsyn.error(
"No sent packet for response with ack=%s, destination=%s:%s",
pkt[1].ack, self.config_destination, self.dst_port,
pkt[1].ack,
self.config_destination,
self.dst_port,
)
match_fail += 1
else:
Expand Down
Loading

0 comments on commit a046f6c

Please sign in to comment.