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
|
local tmp_json
|
||||||
tmp_json=$(mktemp)
|
tmp_json=$(mktemp)
|
||||||
|
|
||||||
local result
|
|
||||||
|
|
||||||
sleep 1s
|
sleep 1s
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
echo "Running iperf3 $mode $direction to $target..."
|
echo "Running iperf3 $mode $direction to $target..." >&2
|
||||||
result=$(iperf3 "${args[@]}" -J >"$tmp_json" 2>"$tmp_err")
|
iperf3 "${args[@]}" -J >"$tmp_json" 2>"$tmp_err"
|
||||||
echo "This took $SECONDS seconds."
|
echo "This took $SECONDS seconds." >&2
|
||||||
|
|
||||||
echo "Parsing iperf3 output..."
|
echo "Parsing iperf3 output..." >&2
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
parsed=$(jq -r '
|
parsed=$(jq -r '
|
||||||
if .error then
|
if .error then
|
||||||
|
@ -98,7 +96,7 @@ run_iperf() {
|
||||||
else
|
else
|
||||||
"unexpected-format"
|
"unexpected-format"
|
||||||
end' "$tmp_json" || echo "execution-failed")
|
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
|
if [[ "$parsed" == "iperf3-error" || "$parsed" == "no-end" || "$parsed" == "unexpected-format" || "$parsed" == "execution-failed" ]]; then
|
||||||
timestamp=$(date -Iseconds)
|
timestamp=$(date -Iseconds)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue