Problem :
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
Solution :
> 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 #
If you are using iperf2 you might want to try the -yC formatting option
[root@localhost iperf2-code]# src/iperf -c 192.168.1.4 -i 1 -yC -t 5
20180510151943,192.168.1.1,42090,192.168.1.4,5001,3,0.0-1.0,63438848,507510784
20180510151944,192.168.1.1,42090,192.168.1.4,5001,3,1.0-2.0,63569920,508559360
20180510151945,192.168.1.1,42090,192.168.1.4,5001,3,2.0-3.0,57802752,462422016
20180510151946,192.168.1.1,42090,192.168.1.4,5001,3,3.0-4.0,57409536,459276288
20180510151947,192.168.1.1,42090,192.168.1.4,5001,3,4.0-5.0,57016320,456130560
20180510151947,192.168.1.1,42090,192.168.1.4,5001,3,0.0-5.0,299237376,478429304
Bob