Linux IPERF3 One-click Automated test Scripts

Source: Internet
Author: User

IPERF3 automated test script with one click:


Date: September 01, 2015
Contact e-mail: [Email protected]
Q q Group: 1851 15701
51CTO Blog Home: http://990487026.blog.51cto.com


Get ready:

1, already installed IPERF3

2,root Permissions


Function:

1, automatically test ping data: Ping delay and ping packet loss, 30 times

2,IPERF3 automatically test TCP upstream bandwidth throughput, Unit kbits/sec

3,IPERF3 automatically tests TCP downlink bandwidth throughput, Unit kbits/sec

4,IPERF3 Automatic test of UDP packet loss and jitter

5, automatically determine whether the IPERF3 is in a zombie state, if so, then kill it, every 300 seconds to check

6, automatically determine whether to get the thought of the data value, if not obtained, will retry, until the data is obtained

7, the parameter specifies:

# Destination IP Address
# $ $ Script Run time, unit: seconds
# $ IPERF3-T's parameters

# $4 Sleep script each run, rest long unit: seconds

How to use:

./iperf14.sh baidu.com 99999 5 10


6, run the script to generate a. CSV data report that can be viewed directly from Excel in office software

The format is as follows:

Localhost, 192.**.**.**remote,54.**.**.**bandwidth Kbits/secdate,start_time,end_time,up_sender,up_receiver,down_ SENDER,DOWN_RECEIVER,JITTER/MS,LOST/TOTAL,PING_LATENCY/MS,PING_LOST2015-09-01, 08:20:44,08:21:38,799,145,359,359,0.147,11%,511.811,0% 2015-09-01,08:21:39,08:22:42,799,145,683,683,0.209,12%, 529.747,0% 2015-09-01,08:22:43,08:23:43,1610,295,556,556,0.190,7.9%,501.740,0% 2015-09-01,08:23:44,08:24:35,608,156,568,568,0.169,11%,496.672,0% 2015-09-01,08:24:36,08:25:35,602,162,567,567,0.377,12%,509.504,0% 2015-09-01,08:25:36,08:26:27,1483,295,707,707,0.278,6.7%,507.316,0%


You can draw a line chart of the collected data,


====================================================================

[email protected]:/iperf.sh/files# cat iperf14.sh #!/bin/bash# modify 2015.08.31  14:05# up ,down bandwidth unit is kbits/sec# $1 for ip  address# $2 .sh run time# $3 iperf3 -t time# $4 sleep  seconds# add ping_lost # retry fun# kill iperf sleep 5#  fix nan error # add supervision iperf3 # add judgement  root# fix file_modify == #### judgement root ######################## ############################################# #root_id = ' id -u ' if [  $root _id -ne 0  ] ; then{   clear   echo -e  "\033[40;37mwarning:  you are not root user ! \n\n[please use command line ]$  sudo su \n\n \033[0m "   exit 10}fi####### get localhost ip & initialization  for iperf.csv########################### #3cleartime4 = ' date + '%s ' Time5=$[time4+$2] mkdir  -p filestime1= ' date  "+%f-%h-%m" ' iperf= "iperf3 -c $1 -t $3 -f k  -p 10000 "ifconfig eth0 > files/tmp1localip= ' sed -n " 2p " files/tmp1 |awk  ' {print $2} ' |cut -d: -f2 ' echo  "Localhost, $localIP"  >>  ./ files/${time1}_iperf.csvecho  "remote,$1"  >> ./files/${time1}_iperf.csvecho  " Bandwidth kbits/sec " >>  ./files/${time1}_iperf.csvecho "  >>   ./files/${time1}_iperf.csvecho  "Date,start_time,end_time,up_sender,up_receiver,down_sender,down_ Receiver,jitter/ms,lost/total,ping_latency/ms,ping_lost " >> ./files/${time1}_iperf.csv#####  supervision iperf3 ############################################ #while  [  $time 4 -le  $time 5 ]do      sleep1=300     file_modify1= ' stat ./files/tmp1 |  tail -n 2| head -n 1| awk  ' {print $3} '       sleep  $sleep 1      file_modify2= ' stat ./files/tmp1 |  tail -n 2| head -n 1| awk  ' {print $3} '       if [  $File _modify1 ==  $File _modify2 ]     then           killall iperf3 >> /dev/null 2> &1          sleep 1           killall iperf3 >> /dev/null 2>&1           echo -e  "' Date '"            echo -e  "\n\n\n\033[43;31m kill zombie iperf3 ..............\033[0m"            sleep 1     else           echo -e  "\033[43;31m iperf3 runing,has  not become zombie ,Every  $sleep 1 seconds check once   ..... \033[0m "     fitime4= ' date + '%s ' done &# begin ##### ######################################## #while  [  $time 4 -le  $time 5 ]do     time2= ' date  "+%f" '             #  get current time    time3= ' date  "+%h:%m:%s" '    echo   "########################################################################## "   echo -e " ' Date ' "    echo  "Get ping information .....ping -c 30 $1"     ping  -c 30 $1 | tee ./files/tmp1     tail -2  Files/tmp1 > ./files/tmp2    ping_latency= ' sed -n  "2p"  ./files /tmp2 | cut -d/ -f5 '     ping_lost= ' sed -n  "1p"  ./files/ tmp2 | awk  ' {print $6} '     echo -e  ' Date '      echo -e  "\033[43;31mping_delay: $ping _latency ms \033[0m"      echo -e  "\033[43;31mping_lost: $ping _lost \033[0m"   echo  "################# ######################################################### "  echo -e " \ nthe ' date '    echo  "Get upload information........  $iperf   "     $iperf  | tee ./files/ tmp1    grep  "Sender"  files/tmp1    stat= ' echo $? '     grep  "Iperf done"  files/tmp1    stat_done= ' echo  $        while  ( [  $stat  != 0 ] | |  [  $stat _done != 0 ] )         do          killall iperf3 >> /dev/null 2> &1         sleep 2          killall iperf3 >> /dev/null 2>&1          echo -e  "' Date '"           echo  "Retry get upload information........  $iperf    "          sleep 5          $iperf   | tee ./ files/tmp1         grep  "Sender"  files/tmp1          stat= ' echo $? '           grep  "Iperf done"  files/tmp1         stat_ Done= ' echo $? '        done    tail -4 ./ Files/tmp1 > ./files/tmp2      up_sender= ' sed -n  "1p"  ./files/tmp2 | awk  ' {print $7} '     up_receiver= ' Sed -n   "2p"  ./files/tmp2 | awk  ' {print $7} '     echo -e  "\033[43;31mup_sender: $up _sender kbits/sec\033[0m "    echo -e " \033[43;31mup_receiver: $up _ receiver kbits/sec\033[0m "  echo " ######################################################## ################## "  echo " get download information........  $iperf  -R    "     $iperf  -r | tee ./files/tmp1    grep   "Sender"  files/tmp1    stat= ' echo $? '     grep  ' Iperf done " files/tmp1    stat_done= ' echo $? '         while  ( [  $stat  != 0 ] | |  [  $stat _done != 0 ] )         do          killall iperf3 >> /dev/null 2> &1         sleep 2         killall iperf3 >> /dev/null  2>&1         echo -e  "' Date '"           echo  "Retry get download information ...   $iperf  -R            sleep 5           $iperf  -R | tee ./files/tmp1          grep  "Sender"  files/tmp1          stat= ' echo $? '          grep  ' Iperf done " files/tmp1         stat_done= ' echo $?"        done    tail -4 ./files/tmp1 >  ./files/tmp2       down_sender= ' sed -n  "1p"  ./files/tmp2 | awk  ' {print  $7} '     down_receiver= ' sed -n  "2p"  ./files/tmp2 | awk   ' {print $7} '     echo -e  ' \033[43;31mdown_sender: $down _sender  kbits/sec\033[0m "    echo -e " \033[43;31mdown_receiver: $down _receiver kbits /sec\033[0m "  echo " ########################################################################## "   echo -e  "get udp information......  $iperf  -u -l 1400  "     $iperf  -u -l 1400  | tee ./files/tmp1     grep  "Sent"  ./files/tmp1    stat= ' echo $? '      grep  "nan"  files/tmp1    stat2= ' echo $? '     grep   "Iperf done" &nbSp;files/tmp1    stat3= ' echo $? '     if [  $stat  -eq  0 ]   then        if [  $stat 2  -eq 0 -o  $stat 3 -ne 0 ]         then           stat=1             fi    fi        while [[  $stat  != 0 ]]       do          killall iperf3 >> /dev/null 2>&1          sleep 1          killall iperf3 >> /dev/null 2>&1          echo -e  "' Date '"          echo  "retry get udp  information........   $iperf  -u -l 1450  "          sleep 1          $iperf  -u -l  1400  | tee ./files/tmp1         grep   "Sent"  ./files/tmp1         stat= ' echo $? '           grep  "Nan"  files/tmp1          stat2= ' echo $? '          grep  ' Iperf done " files/tmp1         stat3= ' echo $?"          if [  $stat  -eq 0 ]          then         if [  $stat 2 -eq 0  -o  $stat 3 -ne 0 ]              then                 stat=1                  fi         fi       done     tail -4 ./files/tmp1 > ./files/tmp2     Jitter= ' sed -n  "1p"  ./files/tmp2 | awk  ' {print $9} '      sed -n  "1p"  ./files/tmp2  |awk  ' {print $12} ' >./files/tmp1     sed -i  "s# (# #g"  ./files/tmp1    sed -i  "s#) # #g"  ./files/tmp1      lost= ' cat ./files/tmp1 '     echo -e  ' \033[43; 31mjitter :  $Jitter \033[0m "    echo -e " \033[43;31mlost:  $Lost  \033[0m "    echo " ############################################################# ############ "    time_end= ' date " +%h:%m:%s "'     echo -e   "\033[43;31mlocal  ip is  $localIP  \033[0m"     echo -e   "\033[43;31mremote ip is $1 \033[0m"     echo  "$time 2, $time 3 , $time _end, $up _sender, $up _receiver, $down _sender, $down _receiver, $Jitter, $Lost, $ping _latency, $ping _lost  "  >> ./files/${time1}_iperf.csv    echo -e  "\033[43;31mrecoder  file save as  ./files/${time1}_iperf.csv \033[0m "    echo  -e  "sleep  $4 seconds #####################################################\n\n\n\n "        sleep $4time4= ' date + '%s ' done rm -rf ./files/tmp1rm -rf  ./files/tmp2clear echo -e  "\033[31m************************************************************ \033[0m "echo -e " information collection complete !                           "dateecho -e " recoder file save as  ./files/${time1}_iperf.csv                   "Echo  -e  "\033[31m*******************************************************************\033[0m"

===================================================================================




This article comes from "Life is endless, tossing and turning." "Blog, be sure to keep this provenance http://990487026.blog.51cto.com/10133282/1690371

Linux IPERF3 One-click Automated test Scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.