无锡营销网站建设,广告网站 源码,wordpress 主页显示多图,网站宝建站助手简介
bench.sh 是一个 Linux 系统性能基准测试工具。它的测试结果如下图#xff1a;给出服务器的整体配置信息#xff0c;IO 性能#xff0c;网络性能。很多人使用它测试 vps 性能。
一键运行
服务器在国外可以使用以下命令运行测试
wget -qO- bench.sh | bash复制…简介
bench.sh 是一个 Linux 系统性能基准测试工具。它的测试结果如下图给出服务器的整体配置信息IO 性能网络性能。很多人使用它测试 vps 性能。
一键运行
服务器在国外可以使用以下命令运行测试
wget -qO- bench.sh | bash复制脚本到本地运行
服务器在国内只能从 github 复制脚本到本地运行。脚本内容已经贴到下面复制代码块保存到 bench.sh 文件中chmod x 赋权, ./bench.sh 运行。
#!/usr/bin/env bash
#
# Description: A Bench Script by Teddysun
#
# Copyright (C) 2015 - 2023 Teddysun iteddysun.com
# Thanks: LookBack admindwhd.org
# URL: https://teddysun.com/444.html
# https://github.com/teddysun/across/blob/master/bench.sh
#
trap _exit INT QUIT TERM_red() {printf \033[0;31;31m%b\033[0m $1
}_green() {printf \033[0;31;32m%b\033[0m $1
}_yellow() {printf \033[0;31;33m%b\033[0m $1
}_blue() {printf \033[0;31;36m%b\033[0m $1
}_exists() {local cmd$1if eval type type /dev/null 21; theneval type $cmd /dev/null 21elif command /dev/null 21; thencommand -v $cmd /dev/null 21elsewhich $cmd /dev/null 21filocal rt$?return ${rt}
}_exit() {_red \nThe script has been terminated. Cleaning up files...\n# clean uprm -fr speedtest.tgz speedtest-cli benchtest_*exit 1
}get_opsy() {[ -f /etc/redhat-release ] awk {print $0} /etc/redhat-release return[ -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
}next() {printf %-70s\n - | sed s/\s/-/g
}speed_test() {local nodeName$2if [ -z $1 ];then./speedtest-cli/speedtest --progressno --accept-license --accept-gdpr ./speedtest-cli/speedtest.log 21else./speedtest-cli/speedtest --progressno --server-id$1 --accept-license --accept-gdpr ./speedtest-cli/speedtest.log 21fiif [ $? -eq 0 ]; thenlocal dl_speed up_speed latencydl_speed$(awk /Download/{print $3 $4} ./speedtest-cli/speedtest.log)up_speed$(awk /Upload/{print $3 $4} ./speedtest-cli/speedtest.log)latency$(awk /Latency/{print $3 $4} ./speedtest-cli/speedtest.log)if [[ -n ${dl_speed} -n ${up_speed} -n ${latency} ]]; thenprintf \033[0;33m%-18s\033[0;32m%-18s\033[0;31m%-20s\033[0;36m%-12s\033[0m\n ${nodeName} ${up_speed} ${dl_speed} ${latency}fifi
}speed() {speed_test Speedtest.netspeed_test 21541 Los Angeles, USspeed_test 43860 Dallas, USspeed_test 40879 Montreal, CAspeed_test 24215 Paris, FRspeed_test 28922 Amsterdam, NLspeed_test 24447 Shanghai, CNspeed_test 5530 Chongqing, CNspeed_test 60572 Guangzhou, CNspeed_test 32155 Hongkong, CNspeed_test 23647 Mumbai, INspeed_test 13623 Singapore, SGspeed_test 21569 Tokyo, JP
}io_test() {(LANGC dd if/dev/zero ofbenchtest_$$ bs512k count$1 convfdatasync rm -f benchtest_$$) 21 | awk -F [,] {io$NF} END { print io} | sed s/^[ \t]*//;s/[ \t]*$//
}calc_size() {local raw$1local total_size0local num1local unitKBif ! [[ ${raw} ~ ^[0-9]$ ]]; thenecho returnfiif [ ${raw} -ge 1073741824 ]; thennum1073741824unitTBelif [ ${raw} -ge 1048576 ]; thennum1048576unitGBelif [ ${raw} -ge 1024 ]; thennum1024unitMBelif [ ${raw} -eq 0 ]; thenecho ${total_size}returnfitotal_size$(awk BEGIN{printf %.1f, $raw / $num})echo ${total_size} ${unit}
}# since calc_size converts kilobyte to MB, GB and TB
# to_kibyte converts zfs size from bytes to kilobyte
to_kibyte() {local raw$1awk BEGIN{printf %.0f, $raw / 1024}
}calc_sum() {local arr($)local ss0for i in ${arr[]}; dos$((s i))doneecho ${s}
}check_virt() {_exists dmesg virtualx$(dmesg 2/dev/null)if _exists dmidecode; thensys_manu$(dmidecode -s system-manufacturer 2/dev/null)sys_product$(dmidecode -s system-product-name 2/dev/null)sys_ver$(dmidecode -s system-version 2/dev/null)elsesys_manusys_productsys_verfiif grep -qa docker /proc/1/cgroup; thenvirtDockerelif grep -qa lxc /proc/1/cgroup; thenvirtLXCelif grep -qa containerlxc /proc/1/environ; thenvirtLXCelif [[ -f /proc/user_beancounters ]]; thenvirtOpenVZelif [[ ${virtualx} *kvm-clock* ]]; thenvirtKVMelif [[ ${sys_product} *KVM* ]]; thenvirtKVMelif [[ ${sys_manu} *QEMU* ]]; thenvirtKVMelif [[ ${cname} *KVM* ]]; thenvirtKVMelif [[ ${cname} *QEMU* ]]; thenvirtKVMelif [[ ${virtualx} *VMware Virtual Platform* ]]; thenvirtVMwareelif [[ ${sys_product} *VMware Virtual Platform* ]]; thenvirtVMwareelif [[ ${virtualx} *Parallels Software International* ]]; thenvirtParallelselif [[ ${virtualx} *VirtualBox* ]]; thenvirtVirtualBoxelif [[ -e /proc/xen ]]; thenif grep -q control_d /proc/xen/capabilities 2/dev/null; thenvirtXen-Dom0elsevirtXen-DomUfielif [ -f /sys/hypervisor/type ] grep -q xen /sys/hypervisor/type; thenvirtXenelif [[ ${sys_manu} *Microsoft Corporation* ]]; thenif [[ ${sys_product} *Virtual Machine* ]]; thenif [[ ${sys_ver} *7.0* || ${sys_ver} *Hyper-V ]]; thenvirtHyper-VelsevirtMicrosoft Virtual MachinefifielsevirtDedicatedfi
}ipv4_info() {local org city country regionorg$(wget -q -T10 -O- ipinfo.io/org)city$(wget -q -T10 -O- ipinfo.io/city)country$(wget -q -T10 -O- ipinfo.io/country)region$(wget -q -T10 -O- ipinfo.io/region)if [[ -n ${org} ]]; thenecho Organization : $(_blue ${org})fiif [[ -n ${city} -n ${country} ]]; thenecho Location : $(_blue ${city} / ${country})fiif [[ -n ${region} ]]; thenecho Region : $(_yellow ${region})fiif [[ -z ${org} ]]; thenecho Region : $(_red No ISP detected)fi
}install_speedtest() {if [ ! -e ./speedtest-cli/speedtest ]; thensys_bitlocal sysarchsysarch$(uname -m)if [ ${sysarch} unknown ] || [ ${sysarch} ]; thensysarch$(arch)fiif [ ${sysarch} x86_64 ]; thensys_bitx86_64fiif [ ${sysarch} i386 ] || [ ${sysarch} i686 ]; thensys_biti386fiif [ ${sysarch} armv8 ] || [ ${sysarch} armv8l ] || [ ${sysarch} aarch64 ] || [ ${sysarch} arm64 ]; thensys_bitaarch64fiif [ ${sysarch} armv7 ] || [ ${sysarch} armv7l ]; thensys_bitarmhffiif [ ${sysarch} armv6 ]; thensys_bitarmelfi[ -z ${sys_bit} ] _red Error: Unsupported system architecture (${sysarch}).\n exit 1url1https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-${sys_bit}.tgzurl2https://dl.lamp.sh/files/ookla-speedtest-1.2.0-linux-${sys_bit}.tgzif ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url1}; thenif ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url2}; then_red Error: Failed to download speedtest-cli.\n exit 1fifimkdir -p speedtest-cli tar zxf speedtest.tgz -C ./speedtest-cli chmod x ./speedtest-cli/speedtestrm -f speedtest.tgzfiprintf %-18s%-18s%-20s%-12s\n Node Name Upload Speed Download Speed Latency
}print_intro() {echo -------------------- A Bench.sh Script By Teddysun -------------------echo Version : $(_green v2023-10-15)echo Usage : $(_red wget -qO- bench.sh | bash)
}# Get System information
get_system_info() {cname$(awk -F: /model name/ {name$2} END {print name} /proc/cpuinfo | sed s/^[ \t]*//;s/[ \t]*$//)cores$(awk -F: /^processor/ {core} END {print core} /proc/cpuinfo)freq$(awk -F[ :] /cpu MHz/ {print $4;exit} /proc/cpuinfo)ccache$(awk -F: /cache size/ {cache$2} END {print cache} /proc/cpuinfo | sed s/^[ \t]*//;s/[ \t]*$//)cpu_aes$(grep -i aes /proc/cpuinfo)cpu_virt$(grep -Ei vmx|svm /proc/cpuinfo)tram$(LANGCfree | awk /Mem/ {print $2})tram$(calc_size $tram)uram$(LANGCfree | awk /Mem/ {print $3})uram$(calc_size $uram)swap$(LANGCfree | awk /Swap/ {print $2})swap$(calc_size $swap)uswap$(LANGCfree | awk /Swap/ {print $3})uswap$(calc_size $uswap)up$(awk {a$1/86400;b($1%86400)/3600;c($1%3600)/60} {printf(%d days, %d hour %d min\n,a,b,c)} /proc/uptime)if _exists w; thenload$(LANGCw | head -1 | awk -Fload average: {print $2} | sed s/^[ \t]*//;s/[ \t]*$//)elif _exists uptime; thenload$(LANGCuptime | head -1 | awk -Fload average: {print $2} | sed s/^[ \t]*//;s/[ \t]*$//)fiopsy$(get_opsy)arch$(uname -m)if _exists getconf; thenlbit$(getconf LONG_BIT)elseecho ${arch} | grep -q 64 lbit64 || lbit32fikern$(uname -r)in_kernel_no_swap_total_size$(LANGCdf -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2/dev/null | grep total | awk { print $2 })swap_total_size$(free -k | grep Swap | awk {print $2})zfs_total_size$(to_kibyte $(calc_sum $(zpool list -o size -Hp 2 /dev/null)))disk_total_size$(calc_size $((swap_total_size in_kernel_no_swap_total_size zfs_total_size)))in_kernel_no_swap_used_size$(LANGCdf -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2/dev/null | grep total | awk { print $3 })swap_used_size$(free -k | grep Swap | awk {print $3})zfs_used_size$(to_kibyte $(calc_sum $(zpool list -o allocated -Hp 2 /dev/null)))disk_used_size$(calc_size $((swap_used_size in_kernel_no_swap_used_size zfs_used_size)))tcpctrl$(sysctl net.ipv4.tcp_congestion_control | awk -F {print $3})
}
# Print System information
print_system_info() {if [ -n $cname ]; thenecho CPU Model : $(_blue $cname)elseecho CPU Model : $(_blue CPU model not detected)fiif [ -n $freq ]; thenecho CPU Cores : $(_blue $cores $freq MHz)elseecho CPU Cores : $(_blue $cores)fiif [ -n $ccache ]; thenecho CPU Cache : $(_blue $ccache)fiif [ -n $cpu_aes ]; thenecho AES-NI : $(_green \xe2\x9c\x93 Enabled)elseecho AES-NI : $(_red \xe2\x9c\x97 Disabled)fiif [ -n $cpu_virt ]; thenecho VM-x/AMD-V : $(_green \xe2\x9c\x93 Enabled)elseecho VM-x/AMD-V : $(_red \xe2\x9c\x97 Disabled)fiecho Total Disk : $(_yellow $disk_total_size) $(_blue ($disk_used_size Used))echo Total Mem : $(_yellow $tram) $(_blue ($uram Used))if [ $swap ! 0 ]; thenecho Total Swap : $(_blue $swap ($uswap Used))fiecho System uptime : $(_blue $up)echo Load average : $(_blue $load)echo OS : $(_blue $opsy)echo Arch : $(_blue $arch ($lbit Bit))echo Kernel : $(_blue $kern)echo TCP CC : $(_yellow $tcpctrl)echo Virtualization : $(_blue $virt)echo IPv4/IPv6 : $online
}print_io_test() {freespace$(df -m . | awk NR2 {print $4})if [ -z ${freespace} ]; thenfreespace$(df -m . | awk NR3 {print $3})fiif [ ${freespace} -gt 1024 ]; thenwritemb2048io1$(io_test ${writemb})echo I/O Speed(1st run) : $(_yellow $io1)io2$(io_test ${writemb})echo I/O Speed(2nd run) : $(_yellow $io2)io3$(io_test ${writemb})echo I/O Speed(3rd run) : $(_yellow $io3)ioraw1$(echo $io1 | awk NR1 {print $1})[[ $(echo $io1 | awk NR1 {print $2}) GB/s ]] ioraw1$(awk BEGIN{print $ioraw1 * 1024})ioraw2$(echo $io2 | awk NR1 {print $1})[[ $(echo $io2 | awk NR1 {print $2}) GB/s ]] ioraw2$(awk BEGIN{print $ioraw2 * 1024})ioraw3$(echo $io3 | awk NR1 {print $1})[[ $(echo $io3 | awk NR1 {print $2}) GB/s ]] ioraw3$(awk BEGIN{print $ioraw3 * 1024})ioall$(awk BEGIN{print $ioraw1 $ioraw2 $ioraw3})ioavg$(awk BEGIN{printf %.1f, $ioall / 3})echo I/O Speed(average) : $(_yellow $ioavg MB/s)elseecho $(_red Not enough space for I/O Speed test!)fi
}print_end_time() {end_time$(date %s)time$((end_time - start_time))if [ ${time} -gt 60 ]; thenmin$((time / 60))sec$((time % 60))echo Finished in : ${min} min ${sec} secelseecho Finished in : ${time} secfidate_time$(date %Y-%m-%d %H:%M:%S %Z)echo Timestamp : $date_time
}! _exists wget _red Error: wget command not found.\n exit 1
! _exists free _red Error: free command not found.\n exit 1
# check for curl/wget
_exists curl local_curltrue
# test if the host has IPv4/IPv6 connectivity
[[ -n ${local_curl} ]] ip_check_cmdcurl -s -m 4 || ip_check_cmdwget -qO- -T 4
ipv4_check$( (ping -4 -c 1 -W 4 ipv4.google.com /dev/null 21 echo true) || ${ip_check_cmd} -4 icanhazip.com 2 /dev/null)
ipv6_check$( (ping -6 -c 1 -W 4 ipv6.google.com /dev/null 21 echo true) || ${ip_check_cmd} -6 icanhazip.com 2 /dev/null)
if [[ -z $ipv4_check -z $ipv6_check ]]; then_yellow Warning: Both IPv4 and IPv6 connectivity were not detected.\n
fi
[[ -z $ipv4_check ]] online$(_red \xe2\x9c\x97 Offline) || online$(_green \xe2\x9c\x93 Online)
[[ -z $ipv6_check ]] online / $(_red \xe2\x9c\x97 Offline) || online / $(_green \xe2\x9c\x93 Online)
start_time$(date %s)
get_system_info
check_virt
clear
print_intro
next
print_system_info
ipv4_info
next
print_io_test
next
install_speedtest speed rm -fr speedtest-cli
next
print_end_time
next
文章转载自: http://www.morning.qwdlj.cn.gov.cn.qwdlj.cn http://www.morning.pcqdf.cn.gov.cn.pcqdf.cn http://www.morning.skrh.cn.gov.cn.skrh.cn http://www.morning.krxzl.cn.gov.cn.krxzl.cn http://www.morning.fnpyk.cn.gov.cn.fnpyk.cn http://www.morning.kxsnp.cn.gov.cn.kxsnp.cn http://www.morning.wnpps.cn.gov.cn.wnpps.cn http://www.morning.mwmxs.cn.gov.cn.mwmxs.cn http://www.morning.ndmbd.cn.gov.cn.ndmbd.cn http://www.morning.nfmtl.cn.gov.cn.nfmtl.cn http://www.morning.txzmy.cn.gov.cn.txzmy.cn http://www.morning.jhrkm.cn.gov.cn.jhrkm.cn http://www.morning.mm27.cn.gov.cn.mm27.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn http://www.morning.smyxl.cn.gov.cn.smyxl.cn http://www.morning.kgltb.cn.gov.cn.kgltb.cn http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn http://www.morning.rzscb.cn.gov.cn.rzscb.cn http://www.morning.gqfbh.cn.gov.cn.gqfbh.cn http://www.morning.yhpl.cn.gov.cn.yhpl.cn http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn http://www.morning.pdwny.cn.gov.cn.pdwny.cn http://www.morning.kjnfs.cn.gov.cn.kjnfs.cn http://www.morning.fdfsh.cn.gov.cn.fdfsh.cn http://www.morning.flqkp.cn.gov.cn.flqkp.cn http://www.morning.mjtft.cn.gov.cn.mjtft.cn http://www.morning.nfgbf.cn.gov.cn.nfgbf.cn http://www.morning.ksqyj.cn.gov.cn.ksqyj.cn http://www.morning.tftw.cn.gov.cn.tftw.cn http://www.morning.rjjys.cn.gov.cn.rjjys.cn http://www.morning.rwdbz.cn.gov.cn.rwdbz.cn http://www.morning.mnnxt.cn.gov.cn.mnnxt.cn http://www.morning.kjfsd.cn.gov.cn.kjfsd.cn http://www.morning.nlglm.cn.gov.cn.nlglm.cn http://www.morning.twwts.com.gov.cn.twwts.com http://www.morning.zgpgl.cn.gov.cn.zgpgl.cn http://www.morning.mpngp.cn.gov.cn.mpngp.cn http://www.morning.dpbdq.cn.gov.cn.dpbdq.cn http://www.morning.trbxt.cn.gov.cn.trbxt.cn http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn http://www.morning.hkng.cn.gov.cn.hkng.cn http://www.morning.alive-8.com.gov.cn.alive-8.com http://www.morning.djwpd.cn.gov.cn.djwpd.cn http://www.morning.dfmjm.cn.gov.cn.dfmjm.cn http://www.morning.zcwwb.cn.gov.cn.zcwwb.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.pcshb.cn.gov.cn.pcshb.cn http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn http://www.morning.zpkfb.cn.gov.cn.zpkfb.cn http://www.morning.hwxxh.cn.gov.cn.hwxxh.cn http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn http://www.morning.gkgr.cn.gov.cn.gkgr.cn http://www.morning.ydwsg.cn.gov.cn.ydwsg.cn http://www.morning.xesrd.com.gov.cn.xesrd.com http://www.morning.clpkp.cn.gov.cn.clpkp.cn http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.mzhhr.cn.gov.cn.mzhhr.cn http://www.morning.lnsnyc.com.gov.cn.lnsnyc.com http://www.morning.znknj.cn.gov.cn.znknj.cn http://www.morning.dbhnx.cn.gov.cn.dbhnx.cn http://www.morning.jgcrr.cn.gov.cn.jgcrr.cn http://www.morning.mdfxn.cn.gov.cn.mdfxn.cn http://www.morning.lgmty.cn.gov.cn.lgmty.cn http://www.morning.sjzsjsm.com.gov.cn.sjzsjsm.com http://www.morning.bkgfp.cn.gov.cn.bkgfp.cn http://www.morning.ftznb.cn.gov.cn.ftznb.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.nzxdz.cn.gov.cn.nzxdz.cn http://www.morning.nytqy.cn.gov.cn.nytqy.cn http://www.morning.rycd.cn.gov.cn.rycd.cn http://www.morning.shuanga.com.cn.gov.cn.shuanga.com.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.wknj.cn.gov.cn.wknj.cn http://www.morning.mttqp.cn.gov.cn.mttqp.cn http://www.morning.qsy40.cn.gov.cn.qsy40.cn http://www.morning.mrcpy.cn.gov.cn.mrcpy.cn http://www.morning.qjrjs.cn.gov.cn.qjrjs.cn http://www.morning.tzrmp.cn.gov.cn.tzrmp.cn