From ebe9fb6a33857088c53dd50854329bf78954bada Mon Sep 17 00:00:00 2001 From: Jensfrank Date: Sat, 29 Jun 2024 00:02:08 +0800 Subject: [PATCH] Update nodeloc_vps_autotest_yabs.sh --- nodeloc_vps_autotest_yabs.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/nodeloc_vps_autotest_yabs.sh b/nodeloc_vps_autotest_yabs.sh index b651c3f..0f3711b 100644 --- a/nodeloc_vps_autotest_yabs.sh +++ b/nodeloc_vps_autotest_yabs.sh @@ -112,8 +112,22 @@ yabs_process_output() { local input="$1" # 去除ANSI转义码 local processed_input=$(echo "$input" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g") - # 过滤不需要的行 - echo "$processed_input" | grep -v -E 'Preparing|Generating|Running [^result]|Performing' + + # 使用 awk 过滤不需要的行,并保留合适的格式 + echo "$processed_input" | awk ' + BEGIN { in_block = 0; block_start = ""; } + /^Basic System Information:/ { in_block = 1; block_start = ""; } + /^iperf3 Network Speed Tests \(IPv4\):/ { in_block = 0; print block_start; } + in_block == 1 { + if (!/^(Preparing|Generating|Running|Performing)/ || /result/) { + if (block_start == "") { + block_start = $0; + } else { + block_start = block_start "\n" $0; + } + } + } + ' } # 运行所有测试