From 3d47561c9d9c6aeda0573eb632057cec308ca0c8 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD Date: Fri, 16 May 2025 17:28:53 +0200 Subject: [PATCH] Improve code with temporary variable `retransmits` --- check_iperf3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check_iperf3.py b/check_iperf3.py index abf6f28..ebdf20d 100755 --- a/check_iperf3.py +++ b/check_iperf3.py @@ -197,10 +197,11 @@ def determine_result(options, json_data) -> Tuple[int, Optional[List[str]]]: statuslines.append("transfer rate below warning threshold") if not options.udp and options.retrans_crit and options.retrans_warn: - if json_data["end"]["sum_sent"]["retransmits"] >= options.retrans_crit: + retransmits = json_data["end"]["sum_sent"]["retransmits"] + if retransmits >= options.retrans_crit: rc = max(rc, 2) statuslines.append("retransmissions over critical threshold") - elif json_data["end"]["sum_sent"]["retransmits"] >= options.retrans_warn: + elif retransmits >= options.retrans_warn: rc = max(rc, 1) statuslines.append("retransmissions over warning threshold")