简体   繁体   中英

Bash script average of iperf result

I'm running iperf multiple times via the following command

iperf -c 1.1.1.1 -t 60 -w 6400 -f m >> iperf.log

sometimes with different arguments. The resulting iperf.log may look like this:

[ 3] local 2.2.2.2 port 51129 connected with 1.1.1.1 port 5001 
[ ID] Interval Transfer Bandwidth 
[ 3] 0.0-20.0 sec 1869 MBytes 784 Mbits/sec
[ 3] local 2.2.2.2 port 51130 connected with 1.1.1.1 port 5001 
[ ID] Interval Transfer Bandwidth 
[ 3] 0.0-15.0 sec 1445 MBytes 808 Mbits/sec

what i'd like to able to do is once it completed to have the average transfer rate outputted ie

 average ....... XXX Mbits/sec

awk is the way to go, you can try something like this:

iperf -c 1.1.1.1 -t 60 -w 6400 -fm|awk -F 'MBytes' {'print $2'} >> iperf.log

You just need to remove the empty lines now, that I will leave to you. :)

Do you need to start and stop it? You might just want to use interval reporting (-i ) You can set i to 15 and set -t to samples desired * 15.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM