I'm currently trying to launch a very long Iperf test on my infrastructure, so I'm developing some powershell script in order to do the tests.
To analyses the results, I want to have the hour/minutes/seconds of each new packet sends per lines on my output.
Currently, I'm using the -T argument like that on my script :
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"
But the output of the command just give me the current time when I launch the command like this:
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
And I cannot find a way to increment the value with the current time without relaunching several times the command iperf3.exe.
Is there any solution to increment the value? I can't do it with a "for"/"while" loop (in my opinion) because it's running a lot of iperf3 instance and it's not what is expected.
For information, I use the last version of iperf3-3.1.3 on Windows.
Thanks in advance for your help.
Judging by iperf3
's documentation:
-T
(--title
) is for defining a static prefix to prepend to each output line, due to passing expandable string "$(Get-Date -Format 'HH:mm:ss')"
as an argument, a static string representing the time at the time of string expansion (interpolation) is used.
By contrast, what you're looking for is the --timestamps
option, which causes a (true, event-related) timestamp to be prepended to each output line.
You can control the specific format of these timestamps via an optional argument, using a format string as used in the Unix strftime()
library function.
These format strings are not compatible with .NET's date/time format strings (as used by Get-Date
, for instance), so HH:mm:ss
does not work; the strftime()
equivalent is: %H:%M:%S
To put it all together:
Start-Process -FilePath 'C:\iperf3.exe' -Verb RunAs -ArgumentList @"
-c $client_IP -t 86400 -p 5102 --logfile C:\toto.txt --timestamps=%H:%M:%S
"@
Note: I've substituted CLIENT_IP
(which I assume was just a pseudo-code placeholder), with variable $client_IP
- adjust as needed.