How can I output iperf results for only Interval and Bandwidth?
5,263
> iperf -c 127.0.0.1 -t 2 -i 0.5 -f m | tee log1 ------------------------------------------------------------ Client connecting to 127.0.0.1, TCP port 5001 TCP window size: 2.50 MByte (default) ------------------------------------------------------------ [ 3] local 127.0.0.1 port 42200 connected with 127.0.0.1 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0- 0.5 sec 449 MBytes 7537 Mbits/sec [ 3] 0.5- 1.0 sec 578 MBytes 9697 Mbits/sec [ 3] 1.0- 1.5 sec 575 MBytes 9649 Mbits/sec [ 3] 1.5- 2.0 sec 587 MBytes 9848 Mbits/sec [ 3] 0.0- 2.0 sec 2190 MBytes 9183 Mbits/sec > awk -F'[ -]+' '/sec/{print $3"-"$4" "$8}' log1 0.0-0.5 7537 0.5-1.0 9697 1.0-1.5 9649 1.5-2.0 9848 0.0-2.0 9183 > iperf -c 127.0.0.1 -t 2 -i 0.5 -f m |\ > awk -Wi -F'[ -]+' '/sec/{print $3"-"$4" "$8}' # interactive results follow #
> iperf -c 127.0.0.1 -t 2 -i 0.5 -xc -yc | tee log2 20180515044354,,,,,3,0.0-0.5,536084480,8577351680 20180515044355,,,,,3,0.5-1.0,602537984,9640607744 20180515044355,,,,,3,1.0-1.5,621805568,9948889088 20180515044356,,,,,3,1.5-2.0,620888064,9934209024 20180515044356,,,,,3,0.0-2.0,2381447168,9524874284 > awk -F, '{print $7" "$9/1e6}' log2 0.0-0.5 8577.35 0.5-1.0 9640.61 1.0-1.5 9948.89 1.5-2.0 9934.21 0.0-2.0 9524.87 > iperf -c 127.0.0.1 -t 2 -i 0.5 -xc -yc | awk -Wi -F, '{print $7" "$9/1e6}' # interactive results follow #
Related videos on Youtube
Author by
Gutsygibbon
Updated on September 18, 2022Comments
-
Gutsygibbon over 1 year
I am trying to get the output from the command
iperf -c 10.0.0.1 -t 3600 -i 2
And only need the Interval and bandwidth fields listed for the entire hour of logging.
I haven't used grep or awk in years upon years.
Help would be awesome!
Sample Output:
------------------------------------------------------------ Client connecting to node2, TCP port 5001 TCP window size: 129 KByte (WARNING: requested 130 KByte) ------------------------------------------------------------ [ 3] local <IP Addr node1> port 2530 connected with <IP Addr node2> port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 19.7 MBytes 15.8 Mbits/sec
Desired Output:
0.0-10.0 15.8
-
Scott - Слава Україні almost 6 yearsHow, exactly, do you consider this to be an answer? Your output does not look very much like what the question is asking for.
-
Nick S almost 6 years
-yC
will format the output as csv, which will then be significantly more parseable. For example, the output from Robert's answer can be piped into something like| cut -d, -f3-4
-
Gutsygibbon almost 6 yearsThis is a cool idea but does not work since bandwidth field does not show. I can parse only Interval here and the rest is IPs or ports
-
guest almost 6 yearsI think I'm done. See previous revision(s) for a mess with sed. Feedback on possible improvement are welcomed.
-
Gutsygibbon almost 6 yearsFantastic, just what I needed. Earned your bounty!