linux自动化测试脚本,linux iperf3 一键自动化测试脚本
jerpf iperf3 一键自动化测试脚本:
更新日期:2015年09月06日
联系邮箱:linux_lcl@163.com
个人博客首页:http://990487026.blog.51cto.com
================================================================
iperf3强大的带宽测试功能,其两个网络节点上安装iperf3即可完成测试,可以看到两个节点的上行速度,上行有效带宽,下行速度,下行有效带宽,带宽抖动,UDP丢包。配合使用ping,可以测试出延时,ping的丢包值。
speedtest不满足测试需求,放弃这种测试方式。
jprerf不满足画图需求,放弃这个画图工具。
准备:
1,已经安装iperf3 http://990487026.blog.51cto.com/10133282/1690460
2,已获取root权限 没有root权限的话请在命令行键入:sudo su 或 sudo -s
功能:
1,自动测试ping的数据: ping延时 与ping 丢包,30次
2,iperf3 自动测试TCP 上行带宽吞吐量,单位Kbits/sec
3,iperf3 自动测试TCP 下行带宽吞吐量,单位Kbits/sec
4,iperf3 自动测试UDP的丢包与抖动
5,自动判断iperf3 是否处于僵死状态,如果是,那么就杀了它,每隔600秒检查一次
6,自动判断是否得到了想到的数据值,如果没有得到,就会重试,直到得到数据为止
7,参数指定:
# $1 目标IP地址
# $2 脚本运行时长, 单位:秒
# $3 iperf3 -t 的参数
# $4 sleep 脚本每次运行,休息时长 单位: 秒
使用方法,如: 运行脚本测试baidu 执行时间999999秒 -t 参数为5 sleep 10秒
./iperf14.sh baidu.com 99999 5 10
8,运行脚本会生成.csv数据报表,可以用office软件中的excel直接查看数据,可以对采集到的数据画图。
iperf3 一键自动化测试脚本 2015-0910更新
====== 脚本开始 ============================================================root@Debian:/home# cat iperf3_V16.sh
#!/bin/bash
# modify 2015.09.06 12:38
# 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 ==
# add Internet_IP
# sleep -t ==> ping -c
# default -p 12345
#### 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############################3
clear
time4=`date +'%s'`
time5=$[time4+$2]
mkdir -p files
time1=`date "+%F-%H-%M"`
iperf="iperf3 -c $1 -t $3 -f k -p 12345"
ifconfig eth0 > files/tmp1
localIP=`sed -n "2p" files/tmp1|awk '{print $2}'|cut -d: -f2`
wget http://members.3322.org/dyndns/getip
Internet_IP=`cat getip`
rm -rf getip
echo "Localhost,Ethernet_IP,$localIP" >> ./files/${time1}_iperf.csv
echo "Localhost,Internet_IP,$Internet_IP" >> ./files/${time1}_iperf.csv
echo "Remote,$1" >> ./files/${time1}_iperf.csv
echo "Bandwidth Kbits/sec" >> ./files/${time1}_iperf.csv
echo "" >> ./files/${time1}_iperf.csv
echo "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 [ $time4 -le $time5 ]
do
sleep1=600
File_Modify1=`stat ./files/tmp1 | tail -n 2| head -n 1| awk '{print $3}'`
sleep $sleep1
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[41;37m kill zombie iperf3 ..............\033[0m"
sleep 1
else
echo -e "\033[42;37m iperf3 Runing,Has not become zombie ,Every $sleep1 Seconds Check Once .........\033[0m"
fi
time4=`date +'%s'`
done &
# Begin ##############################################
while [ $time4 -le $time5 ]
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 $4 $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 "\n\n`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" files/tmp1
stat3=`echo $?`
if [ $stat -eq 0 ]
then
if [ $stat2 -eq 0 -o $stat3 -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 [ $stat2 -eq 0 -o $stat3 -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[45;37mlocal IP is $localIP \033[0m"
echo -e "\033[45;37mremote Ip is $1 \033[0m"
echo "$time2,$time3,$time_end,$up_sender,$up_receiver,$down_sender,$down_receiver,$Jitter,$Lost,$ping_Latency,$ping_lost " >> ./files/${time1}_iperf.csv
echo -e "\033[45;37mrecoder file save as ./files/${time1}_iperf.csv \033[0m"
# echo -e "sleep $4 seconds #####################################################\n\n\n\n"
# sleep $4
time4=`date +'%s'`
done
rm -rf ./files/tmp1
rm -rf ./files/tmp2
clear
echo -e "\033[31m*******************************************************************\033[0m"
echo -e "Information Collection Complete ! "
date
echo -e "recoder file save as ./files/${time1}_iperf.csv "
echo -e "\033[31m*******************************************************************\033[0m"
====== 脚本结束 ======================================================
.
linux自动化测试脚本,linux iperf3 一键自动化测试脚本相关推荐
- linux一键电影网站脚本,Linux下HTML5播放器一键生成脚本
原创内容,转载请注明出处: https://www.myzhenai.com.cn/post/2394.html https://www.myzhenai.com/thread-17969-1-1.h ...
- Linux安装lamp脚本,CentOS LAMP一键安装脚本
LAMP简单介绍 LAMP指的Linux(操作系统).Apache(HTTP 服务器),MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python)的第一个字母缩写, ...
- Linux环境下JDK/Eclipse一键安装脚本
-------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...
- linux 一键脚本搭建,Red5一键安装脚本(LinuxWin):一键搭建你的直播平台
简介 项目重构中 看到bilibili,熊猫TV,斗鱼TV等直播平台你是不是也很眼红呢,这里站长为大家写了一个Red5一键安装脚本. Red5提供基于Flash的流媒体服务的一款基于Java的开源流媒 ...
- linux 端口转发软件,linux端口转发神器Socat一键配置脚本
一.概述 目前常用的端口转发工具有rinetd.Haproxy.iptables.Socat前面2种只能转发TCP,后面TCP/UDP都可以转发.如果是需要udp转发的话,只能选择iptables.S ...
- linux游戏脚本,ubuntu 新手一键配置脚本
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 在gayhub上看到有为linux mint写的脚本,但是感觉国内还是用ubuntu的多一点 所以就写了这个脚本,发在这个神奇的游戏吧,希望能钓到新人哈哈 ...
- html免流脚本,免流一键搭建脚本跑商速度
下面是一个典型的例子,检测字符串中是否包含一个元音字母: 1.普通的方法: IfUCase$(char)="A"OrUCase$(char)="E"OrUCas ...
- [转] *** 一键安装脚本(四合一)
[from] https://teddysun.com/486.html 本脚本适用环境 系统支持:CentOS 6+,Debian 7+,Ubuntu 12+ 内存要求:≥128M 日期 :2017 ...
- Linux安装Flash脚本,Linux(CentOS)下的Shockwave Flash shell一键更新脚本
原创内容,转载请注明出处: https://www.myzhenai.com.cn/post/2318.html https://www.myzhenai.com/thread-17933-1-1.h ...
最新文章
- 一键抓取sqlserver数据结构
- 38 JavaScript中的this指向问题
- python queue模块安装_Python queue包_程序模块 - PyPI - Python中文网
- 我们用4行代码节省了100万 记录与阿里云PCDN相遇全过程
- NEFU705(数论+DP)
- DevC++如何安装自定义头文件并使用
- Asp.net MVC代替php
- python过拟合_梯度下降、过拟合和归一化
- oracle和redis关联查询,redis与oracle之间如何可以实现数据同步
- DirectX 修复
- android网易云桌面歌词,网易云音乐APP怎么开启桌面歌词功能
- mobi电子书如何用安卓手机打开?
- 苹果ocr文字识别工具:Text Scanner
- Intel服务器芯片组区别,不同芯片组的主板有什么区别?
- win10配置docker环境
- 用 Python 对 Excel 表格内数据进行去重、分类,标记异常及分析
- html 注释 实例,超详细的HTML !–…– 注释标签使用实例
- 堪称「神器」的电脑软件
- c语言 -1%10等于多少,一个点指1%还是10%,比如销售总额为1000万的一点是多少?_-一个点是百分之几-数学-荣谌凡同学...
- 2.1.2 Capturing HDR Videos(Advanced High Dynamic Range Imaging )
热门文章
- beast软件linux用法,声卡驱动设置 - 黑苹果驱动高手篇 MultiBeast用法进阶_Linux教程_Linux公社-Linux系统门户网站...
- java中标准输入输出流
- Python 逆向抓取 APP 数据
- C++生成一个随机网络
- LeetCode 题 - 35. 搜索插入位置
- springboot项目访问不到controller方法。
- Python2和Python3正则匹配中文时的编码问题
- ext中ArrayStore,JsonStore,XmlStore的用
- 2.12 主成分分析(上)
- OpenCV中的「透视变换 / 投影变换 / 单应性」—cv.warpPerspective、cv.findHomography