Refactor run_iperf function to improve logging and streamline output handling
This commit is contained in:
parent
0818da0351
commit
e75b3807f9
1 changed files with 6 additions and 8 deletions
12
runtest.sh
12
runtest.sh
|
@ -76,15 +76,13 @@ run_iperf() {
|
|||
local tmp_json
|
||||
tmp_json=$(mktemp)
|
||||
|
||||
local result
|
||||
|
||||
sleep 1s
|
||||
SECONDS=0
|
||||
echo "Running iperf3 $mode $direction to $target..."
|
||||
result=$(iperf3 "${args[@]}" -J >"$tmp_json" 2>"$tmp_err")
|
||||
echo "This took $SECONDS seconds."
|
||||
echo "Running iperf3 $mode $direction to $target..." >&2
|
||||
iperf3 "${args[@]}" -J >"$tmp_json" 2>"$tmp_err"
|
||||
echo "This took $SECONDS seconds." >&2
|
||||
|
||||
echo "Parsing iperf3 output..."
|
||||
echo "Parsing iperf3 output..." >&2
|
||||
SECONDS=0
|
||||
parsed=$(jq -r '
|
||||
if .error then
|
||||
|
@ -98,7 +96,7 @@ run_iperf() {
|
|||
else
|
||||
"unexpected-format"
|
||||
end' "$tmp_json" || echo "execution-failed")
|
||||
echo "This took $SECONDS seconds."
|
||||
echo "This took $SECONDS seconds." >&2
|
||||
|
||||
if [[ "$parsed" == "iperf3-error" || "$parsed" == "no-end" || "$parsed" == "unexpected-format" || "$parsed" == "execution-failed" ]]; then
|
||||
timestamp=$(date -Iseconds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue