Fix iperf-test.sh bandwidth extraction in non-live mode

The awk pattern used $(NF-2) which picked up the retransmit count (0)
instead of the bandwidth value, because the retransmit field sits
between the bandwidth unit and "sender". Search for the bits/sec field
by content instead of position.
This commit is contained in:
Johnathan Corgan
2026-02-18 01:07:04 +00:00
parent 68b9652aa9
commit 06b5a623f9
@@ -65,7 +65,7 @@ iperf_test() {
# Check if we got valid results
if echo "$output" | grep -q "sender"; then
# Extract and display results (get SUM line for aggregate bandwidth)
local bandwidth=$(echo "$output" | grep "\[SUM\].*sender" | tail -1 | awk '{print $(NF-2), $(NF-1)}')
local bandwidth=$(echo "$output" | grep "\[SUM\].*sender" | tail -1 | awk '{for(i=1;i<=NF;i++) if($i ~ /bits\/sec/) {print $(i-1), $i; exit}}')
echo "OK"
echo "Bandwidth: $bandwidth"
PASSED=$((PASSED + 1))