#!/bin/bash
#==============================================================#
# Description: bench test script #
# Author: Teddysun <i@teddysun.com> #
# modify: wwng <wwng@2333.me> #
# Thanks: LookBack <admin@dwhd.org> #
# Visit: https://teddysun.com #
#==============================================================#
get_opsy() {
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
} next() {
printf "%-70s\n" "-" | sed 's/\s/-/g'
} speed_test() {
speedtest=$(wget -4O /dev/null -T300 $1 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
ipaddress=$(ping -c1 -n `awk -F'/' '{print $3}' <<< $1` | awk -F'[()]' '{print $2;exit}')
nodeName=$2
if [ "${#nodeName}" -lt "8" ]; then
echo -e "\e[33m$2\e[0m\t\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
elif [ "${#nodeName}" -lt "13" ]; then
echo -e "\e[33m$2\e[0m\t\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
elif [ "${#nodeName}" -lt "24" ]; then
echo -e "\e[33m$2\e[0m\t\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
elif [ "${#nodeName}" -ge "24" ]; then
echo -e "\e[33m$2\e[0m\t\e[32m$ipaddress\e[0m\t\t\e[31m$speedtest\e[0m"
fi
} speed() {
speed_test 'http://cachefly.cachefly.net/100mb.test' 'CacheFly'
speed_test 'https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jquery-speedtest/100MB.txt' 'Google GCE'
speed_test 'http://speed.0738.cc/ldinfo_vod.rar' 'Loudi Telecom, Hunan, CN'
speed_test 'http://101.95.50.18/test.img' 'Shanghai Telecom, Shanghai, CN'
speed_test 'http://61.157.118.78/download/300.data' 'Suining Telecom, Sichuan, CN'
#speed_test 'http://speed.myzone.cn/pc_elive_1.1.rar' 'China Telecom, Henan, CN'
speed_test 'http://speedtest.newark.linode.com/100MB-newark.bin' 'Linode, Newark, NJ'
speed_test 'http://speedtest.atlanta.linode.com/100MB-atlanta.bin' 'Linode, Atlanta, GA'
speed_test 'http://speedtest.dallas.linode.com/100MB-dallas.bin' 'Linode, Dallas, TX'
speed_test 'http://speedtest.fremont.linode.com/100MB-fremont.bin' 'Linode, Fremont, CA'
speed_test 'http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin' 'Linode, Frankfurt, DE'
speed_test 'http://speedtest.london.linode.com/100MB-london.bin' 'Linode, London, UK'
speed_test 'http://speedtest.singapore.linode.com/100MB-singapore.bin' 'Linode, Singapore, SG'
speed_test 'http://speedtest.tokyo.linode.com/100MB-tokyo.bin' 'Linode, Tokyo, JP'
speed_test 'http://speedtest.AMS01.softlayer.com/downloads/test100.zip' 'Softlayer, Amsterdam, NL'
speed_test 'http://speedtest.CHE01.softlayer.com/downloads/test100.zip' 'Softlayer, Chennai, IN'
#speed_test 'http://speedtest.DAL01.softlayer.com/downloads/test100.zip' 'Softlayer, Dallas, TX'
#speed_test 'http://speedtest.FRA02.softlayer.com/downloads/test100.zip' 'Softlayer, Frankfurt, DE'
speed_test 'http://speedtest.HKG02.softlayer.com/downloads/test100.zip' 'Softlayer, Hong Kong, CN'
speed_test 'http://speedtest.HOU02.softlayer.com/downloads/test100.zip' 'Softlayer, Houston, TX'
#speed_test 'http://speedtest.LON02.softlayer.com/downloads/test100.zip' 'Softlayer, London, UK'
speed_test 'http://speedtest.MEL01.softlayer.com/downloads/test100.zip' 'Softlayer, Melbourne, AU'
speed_test 'http://speedtest.MEX01.softlayer.com/downloads/test100.zip' 'Softlayer, Queretaro, MX'
speed_test 'http://speedtest.MIL01.softlayer.com/downloads/test100.zip' 'Softlayer, Milan, IT'
speed_test 'http://speedtest.MON01.softlayer.com/downloads/test100.zip' 'Softlayer, Montreal, CA'
speed_test 'http://speedtest.PAR01.softlayer.com/downloads/test100.zip' 'Softlayer, Paris, FR'
speed_test 'http://speedtest.SJC01.softlayer.com/downloads/test100.zip' 'Softlayer, San Jose, CA'
speed_test 'http://speedtest.SAO01.softlayer.com/downloads/test100.zip' 'Softlayer, Sao Paulo, BR'
speed_test 'http://speedtest.SEA01.softlayer.com/downloads/test100.zip' 'Softlayer, Seattle, WA'
#speed_test 'http://speedtest.SNG01.softlayer.com/downloads/test100.zip' 'Softlayer, Singapore, SG'
speed_test 'http://speedtest.SYD01.softlayer.com/downloads/test100.zip' 'Softlayer, Sydney, AU'
#speed_test 'http://speedtest.TOK02.softlayer.com/downloads/test100.zip' 'Softlayer, Tokyo, JP'
speed_test 'http://speedtest.TOR01.softlayer.com/downloads/test100.zip' 'Softlayer, Toronto, CA'
speed_test 'http://speedtest.WDC01.softlayer.com/downloads/test100.zip' 'Softlayer, Washington, WA'
speed_test 'http://speedtest-nyc1.digitalocean.com/100mb.test' 'Digitalocean, NewYork, NY'
speed_test 'http://speedtest-ams2.digitalocean.com/100mb.test' 'Digitalocean, Amsterdam, NL'
speed_test 'http://speedtest-sfo1.digitalocean.com/100mb.test' 'Digitalocean, San Francisco, CA'
#speed_test 'http://speedtest-sgp1.digitalocean.com/100mb.test' 'Digitalocean, Singapore, SG'
#speed_test 'http://speedtest-LON1.digitalocean.com/100mb.test' 'Digitalocean, London, UK'
#speed_test 'http://speedtest-FRA1.digitalocean.com/100mb.test' 'Digitalocean, Frankfurt, DE'
#speed_test 'http://speedtest-TOR1.digitalocean.com/100mb.test' 'Digitalocean, Toronto, CA'
speed_test 'http://speedtest-blr1.digitalocean.com/100mb.test' 'Digitalocean, Bengaluru, IN'
speed_test 'http://proof.ovh.net/files/100Mio.dat' 'OVH, Roubaix, FR'
#speed_test 'http://mirror.nl.leaseweb.net/speedtest/100mb.bin' 'LeaseWeb, Amsterdam, NL'
speed_test 'http://mirror.us.leaseweb.net/speedtest/100mb.bin' 'LeaseWeb, Manassas, VA'
speed_test 'http://199.231.208.6/100MB.test' 'Enzu, Chicago, IL'
#speed_test 'http://192.80.186.135/100MB.test' 'Enzu, Dallas, TX'
speed_test 'http://192.157.214.6/100MB.test' 'Enzu, Los Angeles, CA'
#speed_test 'http://172.246.125.7/100MB.test' 'Enzu, Miami, FL'
} io_test() {
(LANG=en_US dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
} cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
tram=$( free -m | awk '/Mem/ {print $2}' )
swap=$( free -m | awk '/Swap/ {print $2}' )
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%ddays, %d:%d:%d\n",a,b,c,d)}' /proc/uptime )
opsy=$( get_opsy )
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
host=$( hostname )
kern=$( uname -r ) clear
next
echo "CPU model : $cname"
echo "Number of cores : $cores"
echo "CPU frequency : $freq MHz"
echo "Total amount of ram : $tram MB"
echo "Total amount of swap : $swap MB"
echo "System uptime : $up"
echo "OS : $opsy"
echo "Arch : $arch ($lbit Bit)"
echo "Kernel : $kern" next if [ -e '/usr/bin/wget' ]; then
echo -e "Node Name\t\t\tIPv4 address\t\tDownload Speed"
speed
else
echo "Error: wget command not found. You must be install wget command at first."
exit 1
fi io1=$( io_test )
io2=$( io_test )
io3=$( io_test )
ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' )
[ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' )
ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
[ "`echo $io2 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' )
ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
[ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' )
ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' )
ioavg=$( awk 'BEGIN{print '$ioall'/3}' )
next
echo "I/O speed(1st run) : $io1"
echo "I/O speed(2nd run) : $io2"
echo "I/O speed(3rd run) : $io3"
echo "Average I/O: $ioavg MB/s"
echo ""

  

bench.sh 跑分测速的更多相关文章

  1. LINUX系统下跑分测试脚本:unixbench.sh

    linux 系统跑分测试脚本:     一.下载脚本:        wget http://teddysun.com/wp-content/uploads/unixbench.sh 二.更改权限:  ...

  2. 网络测速命令--speedtest

    网络测速 speedtest-cli 顾名思义,这个命令为网络测速命令,基于Python编写,测试系统网络的上传下载速度,GitHub托管的项目地址,以下列出常见的用法 安装命令 pip instal ...

  3. iOS炫酷动画图案、多种选择器、网络测速、滑动卡片效果等源码

    iOS精选源码 对网络进行测速 自实现大标题,配合原生骨架屏demo 简单方便的pickerVIew记录数据 LZPickerView 科技风绘制组件,简单快速"画"出炫酷图案 R ...

  4. WiFi 测速

    WiFi 测速 shit 联通 20M => 电信 20M ? https://zhuanlan.zhihu.com/p/86140645 shit 房东 中国电信网络测速 50M http:/ ...

  5. [ Arch Linux ] Arch更新源高速源整理之测速并自动排序高速源 加快更新效率

    方法一: 工具:rankmirrors 0x01 备份原来的源,并创建一个测试源 cd /etc/pacman.d cp mirrorlist mirrorlist.bakcp mirrorlist ...

  6. C# Ping的例子,可用于测试网络,延迟xx毫秒 C#编写网站测速

    C#编写网站测速 WebClient wcl = new WebClient(); Stopwatch spwatch = new Stopwatch(); spwatch.Start(); byte ...

  7. linux测速软件speedtest-cli

    linux测速软件: https://github.com/sivel/speedtest-cli 以下是我在gentoo上测的

  8. 网址测速JS

    /*.route_nav li a:hover{background: #3c7f84 url(title.png) no-repeat;border-color:#84a3a5;}*/ .route ...

  9. 【原创】CLEVO P157SM外接鼠标键盘失灵解决:更换硅脂(附带最新跑分数据)

    作者批注:本文允许转载,并且希望给搜索未来人类.蓝天.CLEVO.更换硅脂或者任何有关关键字的朋友提供帮助. 原文地址:http://www.cnblogs.com/c4isr/p/3514140.h ...

随机推荐

  1. centos svn服务器搭建

    1.安装svnyum install subversion查看安装目录rpm -ql subversion 查看yum安装subversion的位置 2.创建仓库创建版本库目录mkdir -p /va ...

  2. javascript中的scrollTop

    含义:滚动条高度 作用:滚动加载(ajax),滚动导航固定定位,滚动弹框定位等等. 展示滚动导航和侧边栏滚动固定定位的效果:查看效果 1.chrome浏览器 document.body.scrollT ...

  3. Javascript实现格式化输出

    前两天看面试题,其中有一道要实现js的格式化输出,具体给出的是: Javascript实现格式化输出,比如输入999999999,输出为999,999,999 我的实现方式是 function for ...

  4. UIPickerView的使用(二)

    上篇文章 UIPickerView的使用(一)学习了如何创建单列选择器,现在看一下如何创建多列选择器 多列选择器(以二列为例) 1.遵守协议和创建两个数据源 2.创建pickView 3.实现代理 / ...

  5. Json解析,Json-lib

    网络资源参考 http://www.json.org/json-zh.html http://code.alibabatech.com/wiki/pages/viewpage.action?pageI ...

  6. Sharepoint学习笔记—习题系列--70-576习题解析 --索引目录

        Sharepoint学习笔记—习题系列--70-576习题解析  为便于查阅,这里整理并列出了70-576习题解析系列的所有问题,有些内容可能会在以后更新. 需要事先申明的是:     1. ...

  7. 【转】iOS夯实:ARC时代的内存管理

    iOS夯实:ARC时代的内存管理 什么是ARC Automatic Reference Counting (ARC) is a compiler feature that provides autom ...

  8. GIT命令行的使用

    新手了解 有不对的地方指点下 首先, 了解下什么是GIT,GIT是一款开元的分布式版本控制工具, 在世界上的所有分布式版本控制工具中,GIT是最简单,最流行,同时也是最常用的 相比于其他版本的控制工具 ...

  9. jquery数组删除指定元素的方法:grep()

    jquery数组删除指定元素的方法:grep() 金刚 数组 jquery javascript 元素 遇到的问题 今天遇到一个问题,删除数组中的一个指定元素,并返回新的数组. 我定义的js数组是这样 ...

  10. Linux 通过sendmail 发邮件到外部邮箱

    最近在写自动化巡检脚本,想着怎么预警后自动发送邮件报警. 首先下载最新版本mailx-12.4.tar.bz2 # wget http://sourceforge.net/projects/heirl ...