Iperf3 - 将小时/分钟/秒放在每行的开头

问题描述 投票:0回答:3

我目前正在尝试在我的基础设施上启动一个非常长的 Iperf 测试,因此我正在开发一些 powershell 脚本来进行测试。

为了分析结果,我希望在输出中每行发送每个新数据包的小时/分钟/秒。

目前,我在我的脚本中使用 -T 参数:

Start-Process -FilePath "C:\iperf3.exe" -Verb runAs -ArgumentList "-c",CLIENT_IP,"-t","86400","-p",5102,"-T","$(Get-Date -Format 'HH:mm:ss')","--logfile","C:\toto.txt"

但是命令的输出只是给我启动命令时的当前时间,如下所示:

03:40:56:  Connecting to host x.x.x.x, port 5201
03:40:56:  [  4] local x.x.x.x port 41674 connected to x.x.x.x port 5201
03:40:56:  [ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
03:40:56:  [  4]   0.00-1.00   sec   113 MBytes   946 Mbits/sec    0    208 KBytes       
03:40:56:  [  4]   1.00-2.00   sec   112 MBytes   943 Mbits/sec    0    208 KBytes       
03:40:56:  [  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0    210 KBytes       
03:40:56:  [  4]   3.00-4.00   sec   112 MBytes   942 Mbits/sec    0    210 KBytes       
03:40:56:  [  4]   4.00-5.00   sec   112 MBytes   940 Mbits/sec    0    210 KBytes

而且我无法找到一种方法来增加当前时间的值,而无需重新启动命令 iperf3.exe 几次。

有什么办法可以增加这个值吗? 我无法使用“for”/“while”循环(在我看来)来做到这一点,因为它正在运行大量 iperf3 实例,而这不是预期的。

作为信息,我在 Windows 上使用最新版本的 iperf3-3.1.3。

预先感谢您的帮助。

powershell iperf iperf3
3个回答
2
投票

根据

iperf3
的文档判断

  • -T
    (
    --title
    ) 用于定义一个 static 前缀
    以添加到每个输出行之前,因为传递 expandable 字符串
    "$(Get-Date -Format 'HH:mm:ss')"
    作为参数,表示时间 static 字符串在字符串扩展(插值)时使用

  • 相比之下,您正在寻找的是

    --timestamps
    选项,它会导致在每个输出行前面添加一个(真实的、与事件相关的)时间戳。

    • 您可以通过可选参数使用 Unix strftime() 库函数中使用的格式字符串来控制这些时间戳的特定

      format

    • 这些格式字符串与.NET的日期/时间格式字符串兼容(例如,

      Get-Date
      使用的格式字符串),因此
      HH:mm:ss
      确实工作;
      strftime()
      等效项是:
      %H:%M:%S

将所有内容放在一起:

Start-Process -FilePath 'C:\iperf3.exe' -Verb RunAs -ArgumentList @"
 -c $client_IP -t 86400 -p 5102 --logfile C:\toto.txt --timestamps=%H:%M:%S
"@

注意:我用变量

CLIENT_IP
替换了
$client_IP
(我认为这只是一个伪代码占位符) - 根据需要进行调整。


0
投票

您是否尝试过使用

--interval
--verbose
(了解详细信息)选项?


0
投票

我最近在一个类似的老问题上发表了一篇post,但这也适合发布。如果您有能力下载和安装,您可以从这篇neowin帖子中提到的非官方版本下载适用于Windows的较新的iperf3二进制文件。如前所述,从 iperf3.9 开始,添加了

--timestamps
标志以允许添加前缀时间戳:

PS C:\Users\kyrlon> iperf3 -c 127.0.0.1 --timestamp
Thu Apr  4 17:32:38 2024 Connecting to host 127.0.0.1, port 5201
Thu Apr  4 17:32:38 2024 [  5] local 127.0.0.1 port 33864 connected to 127.0.0.1 port 5201
Thu Apr  4 17:32:39 2024 [ ID] Interval           Transfer     Bitrate
Thu Apr  4 17:32:39 2024 [  5]   0.00-1.00   sec   581 MBytes  4.86 Gbits/sec
Thu Apr  4 17:32:40 2024 [  5]   1.00-2.00   sec   578 MBytes  4.84 Gbits/sec
Thu Apr  4 17:32:41 2024 [  5]   2.00-3.00   sec   704 MBytes  5.92 Gbits/sec
Thu Apr  4 17:32:42 2024 [  5]   3.00-4.00   sec   778 MBytes  6.53 Gbits/sec
Thu Apr  4 17:32:43 2024 [  5]   4.00-5.00   sec   746 MBytes  6.25 Gbits/sec
Thu Apr  4 17:32:44 2024 [  5]   5.00-6.00   sec   796 MBytes  6.66 Gbits/sec
Thu Apr  4 17:32:45 2024 [  5]   6.00-7.00   sec   708 MBytes  5.96 Gbits/sec
Thu Apr  4 17:32:46 2024 [  5]   7.00-8.00   sec   790 MBytes  6.63 Gbits/sec
Thu Apr  4 17:32:47 2024 [  5]   8.00-9.00   sec   815 MBytes  6.84 Gbits/sec
Thu Apr  4 17:32:48 2024 [  5]   9.00-10.00  sec   881 MBytes  7.38 Gbits/sec
Thu Apr  4 17:32:48 2024 - - - - - - - - - - - - - - - - - - - - - - - - -
Thu Apr  4 17:32:48 2024 [ ID] Interval           Transfer     Bitrate
Thu Apr  4 17:32:48 2024 [  5]   0.00-10.00  sec  7.20 GBytes  6.19 Gbits/sec                  sender
Thu Apr  4 17:32:48 2024 [  5]   0.00-10.00  sec  7.20 GBytes  6.18 Gbits/sec                  receiver
Thu Apr  4 17:32:48 2024
Thu Apr  4 17:32:48 2024 iperf Done.
© www.soinside.com 2019 - 2024. All rights reserved.