mirror of
https://github.com/masonr/yet-another-bench-script.git
synced 2025-06-28 01:06:54 +00:00
Removed ioping; Added comments; Fixed output format; Updated readme
This commit is contained in:
parent
4946886ebb
commit
a52c3137a5
74
README.md
74
README.md
@ -21,7 +21,7 @@ curl https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/ya
|
||||
./yabs.sh -{dig}
|
||||
```
|
||||
|
||||
* `-d` this option disables the dd/ioping (disk performance) test
|
||||
* `-d` this option disables the dd (disk performance) test
|
||||
* `-i` this option disables the iperf (network performance) test
|
||||
* `-g` this option disables the Geekbench (system performance) test
|
||||
|
||||
@ -29,72 +29,82 @@ Options can be grouped together to skip multiple tests, i.e. `./yabs -dg` to ski
|
||||
|
||||
## Tests Conducted
|
||||
|
||||
* **dd** & **ioping** - the dd utility is utilized to test sequential write disk performance and the ioping utility is used to test sequential read disk performance.
|
||||
* **dd** - the dd utility is utilized to test sequential write and read disk performance.
|
||||
* **iperf3** - the industry standard for testing download and upload speeds to various locations. This script utilizes iperf3 with 8 parallel threads and tests both download and upload speeds. If an iperf server is busy after 10 tries, the speed test for that location/direction is skipped.
|
||||
* **Geekbench 4** - Geekbench is a benchmarking program that measures system performance, which is widely used in the tech community. The web URL is displayed to be able to see complete test and individual benchmark results and allow comparison to other geekbench'd systems. The claim URL to add the Geekbench 4 result to your Geekbench profile is written to a file in the directory that this script is executed from.
|
||||
|
||||
### Note on Disk Performance Test
|
||||
|
||||
This script uses dd's sequential throughput test in order to test both write and read speeds to the disk. It is well known that sequential disk speeds are not necessarily indicative of actual, real-world performance. A superior method to testing disk performance using real-world scenarios is [fio (Flexible I/O Tester)](https://github.com/axboe/fio). Fio was not utilized within this script because the program needs to be compiled and installed on the user's system to run correctly, thus clashes with YABS' tenet to not require any dependencies (installed or compiled) or admin rights to run the script. The sequential dd tests are merely provided as a convienence for the end user.
|
||||
|
||||
### Security Notice
|
||||
|
||||
This script relies on two external binaries in order to complete the network and system performance tests. For the network test, an iperf3 binary and shared library are downloaded from the official source at iperf.fr. For the system test, a Geekbench 4 tarball is downloaded, extracted, and the resulting binary is run. The security risks of running these binaries are minimal, however, use this script at your own risk as you would with any script publicly available on the net.
|
||||
|
||||
## Example Output
|
||||
|
||||
```
|
||||
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
|
||||
# Yet-Another-Bench-Script #
|
||||
# v2019-10-08 #
|
||||
# v2020-01-08 #
|
||||
# https://github.com/masonr/yet-another-bench-script #
|
||||
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
|
||||
|
||||
Tue Oct 8 12:27:29 EDT 2019
|
||||
Wed 08 Jan 2020 07:33:21 PM UTC
|
||||
|
||||
Basic System Information:
|
||||
---------------------------------
|
||||
Processor : Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz
|
||||
CPU cores : 8 @ 1600.270 MHz
|
||||
Processor : Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz
|
||||
CPU cores : 8 @ 4098.759 MHz
|
||||
AES-NI : ✔ Enabled
|
||||
VM-x/AMD-V : ✔ Enabled
|
||||
RAM : 31G
|
||||
Swap : 7.5G
|
||||
Disk : 213G
|
||||
RAM : 31Gi
|
||||
Swap : 0B
|
||||
Disk : 221G
|
||||
|
||||
Disk Speed Tests:
|
||||
dd Sequential Disk Speed Tests:
|
||||
---------------------------------
|
||||
| Test 1 | Test 2 | Test 3 | Avg
|
||||
| | | |
|
||||
Write | 363.00 MB/s | 361.00 MB/s | 354.00 MB/s | 359.33 MB/s
|
||||
Read | 411.58 MB/s | 399.94 MB/s | 398.18 MB/s | 403.23 MB/s
|
||||
Write | 291 MB/s | 286 MB/s | 281 MB/s | 286.00 MB/s
|
||||
Read | 179 MB/s | 188 MB/s | 179 MB/s | 182.00 MB/s
|
||||
|
||||
iperf3 Network Speed Tests (IPv4):
|
||||
---------------------------------
|
||||
Provider | Location (Link) | Send Speed | Recv Speed
|
||||
| | |
|
||||
Bouygues Telecom | Paris, FR (10G) | 348 Mbits/sec | 223 Mbits/sec
|
||||
Online.net | Paris, FR (10G) | 770 Mbits/sec | 142 Mbits/sec
|
||||
Severius | The Netherlands (10G) | 687 Mbits/sec | 106 Mbits/sec
|
||||
Worldstream | The Netherlands (10G) | 739 Mbits/sec | 86.1 Mbits/sec
|
||||
wilhelm.tel | Hamburg, DE (10G) | 775 Mbits/sec | 85.0 Mbits/sec
|
||||
Biznet | Bogor, Indonesia (1G) | busy | busy
|
||||
Hostkey | Moscow, RU (1G) | 639 Mbits/sec | 438 Mbits/sec
|
||||
Velocity Online | Tallahassee, FL, US (10G) | 852 Mbits/sec | 312 Mbits/sec
|
||||
Airstream Communications | Eau Claire, WI, US (10G) | 806 Mbits/sec | 114 Mbits/sec
|
||||
Hurricane Electric | Fremont, CA, US (10G) | 728 Mbits/sec | busy
|
||||
Bouygues Telecom | Paris, FR (10G) | 2.93 Gbits/sec | 7.80 Gbits/sec
|
||||
Online.net | Paris, FR (10G) | 7.79 Gbits/sec | 5.20 Gbits/sec
|
||||
Severius | The Netherlands (10G) | 8.98 Gbits/sec | 2.53 Gbits/sec
|
||||
Worldstream | The Netherlands (10G) | 8.65 Gbits/sec | 8.57 Gbits/sec
|
||||
wilhelm.tel | Hamburg, DE (10G) | 7.80 Gbits/sec | 9.03 Gbits/sec
|
||||
Biznet | Bogor, Indonesia (1G) | 752 Mbits/sec | busy
|
||||
Hostkey | Moscow, RU (1G) | 905 Mbits/sec | 449 Mbits/sec
|
||||
Vultr | Piscataway, NJ, US (1G) | 448 Mbits/sec | 51.6 Mbits/sec
|
||||
Velocity Online | Tallahassee, FL, US (10G) | 1.74 Gbits/sec | 1.61 Gbits/sec
|
||||
Airstream Communications | Eau Claire, WI, US (10G) | 1.61 Gbits/sec | 106 Mbits/sec
|
||||
Hurricane Electric | Fremont, CA, US (10G) | 28.2 Mbits/sec | 476 Mbits/sec
|
||||
|
||||
iperf3 Network Speed Tests (IPv6):
|
||||
---------------------------------
|
||||
Provider | Location (Link) | Send Speed | Recv Speed
|
||||
| | |
|
||||
Bouygues Telecom | Paris, FR (10G) | 724 Mbits/sec | 241 Mbits/sec
|
||||
Online.net | Paris, FR (10G) | 608 Mbits/sec | 93.6 Mbits/sec
|
||||
Severius | The Netherlands (10G) | 291 Mbits/sec | 103 Mbits/sec
|
||||
Worldstream | The Netherlands (10G) | 699 Mbits/sec | 80.4 Mbits/sec
|
||||
wilhelm.tel | Hamburg, DE (10G) | 630 Mbits/sec | 77.3 Mbits/sec
|
||||
Airstream Communications | Eau Claire, WI, US (10G) | 783 Mbits/sec | 190 Mbits/sec
|
||||
Hurricane Electric | Fremont, CA, US (10G) | busy | busy
|
||||
Bouygues Telecom | Paris, FR (10G) | 7.78 Gbits/sec | 6.00 Gbits/sec
|
||||
Online.net | Paris, FR (10G) | 2.86 Gbits/sec | 5.74 Gbits/sec
|
||||
Severius | The Netherlands (10G) | 6.96 Gbits/sec | 2.38 Gbits/sec
|
||||
Worldstream | The Netherlands (10G) | 7.29 Gbits/sec | 6.02 Gbits/sec
|
||||
wilhelm.tel | Hamburg, DE (10G) | 4.64 Gbits/sec | 8.93 Gbits/sec
|
||||
Vultr | Piscataway, NJ, US (1G) | 97.5 Mbit/sec | 37.3 Mbits/sec
|
||||
Airstream Communications | Eau Claire, WI, US (10G) | busy | busy
|
||||
Hurricane Electric | Fremont, CA, US (10G) | 348 Mbits/sec | 505 Mbits/sec
|
||||
|
||||
Geekbench 4 Benchmark Test:
|
||||
---------------------------------
|
||||
Test | Value
|
||||
|
|
||||
Single Core | 4015
|
||||
Multi Core | 13157
|
||||
Full Test | https://browser.geekbench.com/v4/cpu/14775012
|
||||
Single Core | 5714
|
||||
Multi Core | 19758
|
||||
Full Test | https://browser.geekbench.com/v4/cpu/15115430
|
||||
|
||||
```
|
||||
|
||||
|
214
yabs.sh
214
yabs.sh
@ -1,14 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Yet Another Bench Script by Mason Rowe
|
||||
# Initial Oct 2019; Updated Jan 2020
|
||||
#
|
||||
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
|
||||
# relayed to me via the GitHub project page linked below.
|
||||
#
|
||||
# Purpose: The purpose of this script is to quickly gauge the performance of a Linux-
|
||||
# based server by benchmarking network performance via iperf3, CPU and
|
||||
# overall system performance via Geekbench 4, and simple sequential disk
|
||||
# performance via dd. The script is designed to not require any dependencies
|
||||
# - either compiled or installed - nor admin privileges to run.
|
||||
#
|
||||
|
||||
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
||||
echo -e '# Yet-Another-Bench-Script #'
|
||||
echo -e '# v2019-10-08 #'
|
||||
echo -e '# v2020-01-08 #'
|
||||
echo -e '# https://github.com/masonr/yet-another-bench-script #'
|
||||
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
||||
|
||||
echo -e
|
||||
date
|
||||
|
||||
# gather basic system information (inc. CPU, AES-NI/virt status, RAM + swap + disk size)
|
||||
echo -e
|
||||
echo -e "Basic System Information:"
|
||||
echo -e "---------------------------------"
|
||||
@ -27,12 +41,15 @@ TOTAL_RAM=$(free -h | awk 'NR==2 {print $2}')
|
||||
echo -e "RAM : $TOTAL_RAM"
|
||||
TOTAL_SWAP=$(free -h | grep Swap | awk '{ print $2 }')
|
||||
echo -e "Swap : $TOTAL_SWAP"
|
||||
# total disk size is calculated by adding all partitions of the types listed below (after the -t flags)
|
||||
TOTAL_DISK=$(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total -h | grep total | awk '{ print $2 }')
|
||||
echo -e "Disk : $TOTAL_DISK"
|
||||
|
||||
# create a directory in the same location that the script is being run to temporarily store YABS-related files
|
||||
DATE=`date -Iseconds | sed -e "s/:/_/g"`
|
||||
YABS_PATH=./$DATE
|
||||
touch $DATE.test 2> /dev/null
|
||||
# test if the user has write permissions in the current directory and exit if not
|
||||
if [ ! -f "$DATE.test" ]; then
|
||||
echo -e
|
||||
echo -e "You do not have write permission in this directory. Switch to an owned directory and re-run the script.\nExiting..."
|
||||
@ -41,10 +58,12 @@ fi
|
||||
rm $DATE.test
|
||||
mkdir -p $YABS_PATH
|
||||
|
||||
# flags to skip certain performance tests
|
||||
SKIP_DISK=""
|
||||
SKIP_IPERF=""
|
||||
SKIP_GEEKBENCH=""
|
||||
|
||||
# get any arguments that were passed to the script and set the associated skip flags (if applicable)
|
||||
while getopts 'dig' flag; do
|
||||
case "${flag}" in
|
||||
d) SKIP_DISK="True" ;;
|
||||
@ -54,41 +73,54 @@ while getopts 'dig' flag; do
|
||||
esac
|
||||
done
|
||||
|
||||
# disk_test
|
||||
# Purpose: This method is designed to test the disk performance of the host using the partition that the
|
||||
# script is being run from using dd sequential speed tests and averaging the results.
|
||||
# Parameters:
|
||||
# - (none)
|
||||
function disk_test {
|
||||
I=0
|
||||
DISK_WRITE_TEST_RES=()
|
||||
DISK_READ_TEST_RES=()
|
||||
DISK_WRITE_TEST_AVG=0
|
||||
DISK_READ_TEST_AVG=0
|
||||
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
|
||||
# run the disk speed tests (write and read) thrice over
|
||||
while [ $I -lt 3 ]
|
||||
do
|
||||
# write test using dd, "direct" flag is used to test direct I/O for data being stored to disk
|
||||
DISK_WRITE_TEST=$(dd if=/dev/zero of=$DISK_PATH/$DATE.test bs=64k count=16k oflag=direct |& grep copied | awk '{ print $(NF-1) " " $(NF)}')
|
||||
VAL=$(echo $DISK_WRITE_TEST | cut -d " " -f 1)
|
||||
[[ "$DISK_WRITE_TEST" == *"GB"* ]] && VAL=$(awk -v a="$VAL" 'BEGIN { print a * 1000 }')
|
||||
DISK_WRITE_TEST_RES+=( "$VAL" )
|
||||
DISK_WRITE_TEST_RES+=( "$DISK_WRITE_TEST" )
|
||||
DISK_WRITE_TEST_AVG=$(awk -v a="$DISK_WRITE_TEST_AVG" -v b="$VAL" 'BEGIN { print a + b }')
|
||||
|
||||
DISK_READ_TEST=$($DISK_PATH/ioping -R -L -D -B -w 6 . | awk '{ print $4 / 1000 / 1000 }')
|
||||
# read test using dd using the 1G file written during the write test
|
||||
DISK_READ_TEST=$(dd if=$DISK_PATH/$DATE.test of=/dev/null bs=8k |& grep copied | awk '{ print $(NF-1) " " $(NF)}')
|
||||
VAL=$(echo $DISK_READ_TEST | cut -d " " -f 1)
|
||||
[[ "$DISK_READ_TEST" == *"GB"* ]] && VAL=$(awk -v a="$VAL" 'BEGIN { pring a * 1000 }')
|
||||
DISK_READ_TEST_RES+=( "$DISK_READ_TEST" )
|
||||
DISK_READ_TEST_AVG=$(awk -v a="$DISK_READ_TEST_AVG" -v b="$DISK_READ_TEST" 'BEGIN { print a + b }')
|
||||
DISK_READ_TEST_AVG=$(awk -v a="$DISK_READ_TEST_AVG" -v b="$VAL" 'BEGIN { print a + b }')
|
||||
|
||||
I=$(( $I + 1 ))
|
||||
done
|
||||
# calculate the write and read speed averages using the results from the three runs
|
||||
DISK_WRITE_TEST_AVG=$(awk -v a="$DISK_WRITE_TEST_AVG" 'BEGIN { print a / 3 }')
|
||||
DISK_READ_TEST_AVG=$(awk -v a="$DISK_READ_TEST_AVG" 'BEGIN { print a / 3 }')
|
||||
}
|
||||
|
||||
# if the skip disk flag was set, skip the disk performance test, otherwise test disk performance
|
||||
if [ -z "$SKIP_DISK" ]; then
|
||||
echo -e "Performing disk performance test. This may take a couple minutes to complete..."
|
||||
echo -en "\nPerforming disk performance test. This may take a couple minutes to complete..."
|
||||
|
||||
# create temp directory to store disk write/read test files
|
||||
DISK_PATH=$YABS_PATH/disk
|
||||
mkdir -p $DISK_PATH
|
||||
curl -s https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/ioping -o $DISK_PATH/ioping
|
||||
chmod +x $DISK_PATH/ioping
|
||||
|
||||
# execute disk performance test
|
||||
disk_test
|
||||
|
||||
# format the speed averages by converting to GB/s if > 1000 MB/s
|
||||
if [ $(echo $DISK_WRITE_TEST_AVG | cut -d "." -f 1) -ge 1000 ]; then
|
||||
DISK_WRITE_TEST_AVG=$(awk -v a="$DISK_WRITE_TEST_AVG" 'BEGIN { print a / 1000 }')
|
||||
DISK_WRITE_TEST_UNIT="GB/s"
|
||||
@ -102,86 +134,146 @@ if [ -z "$SKIP_DISK" ]; then
|
||||
DISK_READ_TEST_UNIT="MB/s"
|
||||
fi
|
||||
|
||||
echo -en "\e[1A"; echo -e "\e[0K\r"
|
||||
echo -e "Disk Speed Tests:"
|
||||
# print dd sequential disk speed test results
|
||||
echo -en "\r\033[0K"
|
||||
echo -e "dd Sequential Disk Speed Tests:"
|
||||
echo -e "---------------------------------"
|
||||
printf "%-6s | %-6s %-4s | %-6s %-4s | %-6s %-4s | %-6s %-4s\n" "" "Test 1" "" "Test 2" "" "Test 3" "" "Avg" ""
|
||||
printf "%-6s | %-6s %-4s | %-6s %-4s | %-6s %-4s | %-6s %-4s\n"
|
||||
printf "%-6s | %-6.2f MB/s | %-6.2f MB/s | %-6.2f MB/s | %-6.2f %-4s\n" "Write" "${DISK_WRITE_TEST_RES[0]}" "${DISK_WRITE_TEST_RES[1]}" "${DISK_WRITE_TEST_RES[2]}" "${DISK_WRITE_TEST_AVG}" "${DISK_WRITE_TEST_UNIT}"
|
||||
printf "%-6s | %-6.2f MB/s | %-6.2f MB/s | %-6.2f MB/s | %-6.2f %-4s\n" "Read" "${DISK_READ_TEST_RES[0]}" "${DISK_READ_TEST_RES[1]}" "${DISK_READ_TEST_RES[2]}" "${DISK_READ_TEST_AVG}" "${DISK_READ_TEST_UNIT}"
|
||||
printf "%-6s | %-11s | %-11s | %-11s | %-6.2f %-4s\n" "Write" "${DISK_WRITE_TEST_RES[0]}" "${DISK_WRITE_TEST_RES[1]}" "${DISK_WRITE_TEST_RES[2]}" "${DISK_WRITE_TEST_AVG}" "${DISK_WRITE_TEST_UNIT}"
|
||||
printf "%-6s | %-11s | %-11s | %-11s | %-6.2f %-4s\n" "Read" "${DISK_READ_TEST_RES[0]}" "${DISK_READ_TEST_RES[1]}" "${DISK_READ_TEST_RES[2]}" "${DISK_READ_TEST_AVG}" "${DISK_READ_TEST_UNIT}"
|
||||
fi
|
||||
|
||||
# iperf_test
|
||||
# Purpose: This method is designed to test the network performance of the host by executing an
|
||||
# iperf3 test to/from the public iperf server passed to the function. Both directions
|
||||
# (send and recieve) are tested.
|
||||
# Parameters:
|
||||
# 1. URL - URL/domain name of the iperf server
|
||||
# 2. PORTS - the range of ports on which the iperf server operates
|
||||
# 3. HOST - the friendly name of the iperf server host/owner
|
||||
# 4. FLAGS - any flags that should be passed to the iperf command
|
||||
function iperf_test {
|
||||
URL=$1
|
||||
PORTS=$2
|
||||
FLAGS=$3
|
||||
HOST=$3
|
||||
FLAGS=$4
|
||||
|
||||
I=0
|
||||
while [ $I -lt 10 ]
|
||||
# attempt the iperf send test 10 times, allowing for a slot to become available on the
|
||||
# server or to throw out any bad/error results
|
||||
I=1
|
||||
while [ $I -le 10 ]
|
||||
do
|
||||
echo -en "Performing $MODE iperf3 send test to $HOST (Attempt #$I of 10)..."
|
||||
# select a random iperf port from the range provided
|
||||
PORT=`shuf -i $PORTS -n 1`
|
||||
# run the iperf test sending data from the host to the iperf server; includes
|
||||
# a timeout of 15s in case the iperf server is not responding; uses 8 parallel
|
||||
# threads for the network test
|
||||
IPERF_RUN_SEND="$(LD_LIBRARY_PATH=$IPERF_PATH timeout 15 $IPERF_PATH/iperf3 $FLAGS -c $URL -p $PORT -P 8)"
|
||||
# check if iperf exited cleanly and did not return an error
|
||||
if [[ "$IPERF_RUN_SEND" == *"receiver"* && "$IPERF_RUN_SEND" != *"error"* ]]; then
|
||||
# test did not result in an error, parse speed result
|
||||
SPEED=$(echo "${IPERF_RUN_SEND}" | grep SUM | grep receiver | awk '{ print $6 }')
|
||||
[[ -z $SPEED || "$SPEED" == "0.00" ]] && I=$(( $I + 1 )) || I=10
|
||||
# if speed result is blank or bad (0.00), rerun, otherwise set counter to exit loop
|
||||
[[ -z $SPEED || "$SPEED" == "0.00" ]] && I=$(( $I + 1 )) || I=11
|
||||
else
|
||||
[[ "$IPERF_RUN_SEND" == *"unable to connect"* ]] && I=10 || I=$(( $I + 1 )) && sleep 2
|
||||
# if iperf server is not responding, set counter to exit, otherwise increment, sleep, and rerun
|
||||
[[ "$IPERF_RUN_SEND" == *"unable to connect"* ]] && I=11 || I=$(( $I + 1 )) && sleep 2
|
||||
fi
|
||||
echo -en "\r\033[0K"
|
||||
done
|
||||
|
||||
J=0
|
||||
while [ $J -lt 10 ]
|
||||
# small sleep necessary to give iperf server a breather to get ready for a new test
|
||||
sleep 1
|
||||
|
||||
# attempt the iperf recieve test 10 times, allowing for a slot to become available on
|
||||
# the server or to throw out any bad/error results
|
||||
J=1
|
||||
while [ $J -le 10 ]
|
||||
do
|
||||
echo -n "Performing $MODE iperf3 recv test from $HOST (Attempt #$J of 10)..."
|
||||
# select a random iperf port from the range provided
|
||||
PORT=`shuf -i $PORTS -n 1`
|
||||
IPERF_RUN_RECV="$(LD_LIBRARY_PATH=$IPERF_PATH timeout 15 $IPERF_PATH/iperf3 -c $URL -p $PORT -P 8 -R)"
|
||||
# run the iperf test recieving data from the iperf server to the host; includes
|
||||
# a timeout of 15s in case the iperf server is not responding; uses 8 parallel
|
||||
# threads for the network test
|
||||
IPERF_RUN_RECV="$(LD_LIBRARY_PATH=$IPERF_PATH timeout 15 $IPERF_PATH/iperf3 $FLAGS -c $URL -p $PORT -P 8 -R)"
|
||||
# check if iperf exited cleanly and did not return an error
|
||||
if [[ "$IPERF_RUN_RECV" == *"receiver"* && "$IPERF_RUN_RECV" != *"error"* ]]; then
|
||||
# test did not result in an error, parse speed result
|
||||
SPEED=$(echo "${IPERF_RUN_RECV}" | grep SUM | grep receiver | awk '{ print $6 }')
|
||||
[[ -z $SPEED || "$SPEED" == "0.00" ]] && J=$(( $J + 1 )) || J=10
|
||||
# if speed result is blank or bad (0.00), rerun, otherwise set counter to exit loop
|
||||
[[ -z $SPEED || "$SPEED" == "0.00" ]] && J=$(( $J + 1 )) || J=11
|
||||
else
|
||||
[[ "$IPERF_RUN_RECV" == *"unable to connect"* ]] && J=10 || J=$(( $J + 1 )) && sleep 2
|
||||
# if iperf server is not responding, set counter to exit, otherwise increment, sleep, and rerun
|
||||
[[ "$IPERF_RUN_RECV" == *"unable to connect"* ]] && J=11 || J=$(( $J + 1 )) && sleep 2
|
||||
fi
|
||||
echo -en "\r\033[0K"
|
||||
done
|
||||
|
||||
# parse the resulting send and recieve speed results
|
||||
IPERF_SENDRESULT="$(echo "${IPERF_RUN_SEND}" | grep SUM | grep receiver)"
|
||||
IPERF_RECVRESULT="$(echo "${IPERF_RUN_RECV}" | grep SUM | grep receiver)"
|
||||
}
|
||||
|
||||
# launch_iperf
|
||||
# Purpose: This method is designed to facilitate the execution of iperf network speed tests to
|
||||
# each public iperf server in the iperf server locations array.
|
||||
# Parameters:
|
||||
# 1. MODE - indicates the type of iperf tests to run (IPv4 or IPv6)
|
||||
function launch_iperf {
|
||||
MODE=$1
|
||||
[[ "$MODE" == *"IPv6"* ]] && IPERF_FLAGS="-6" || IPERF_FLAGS=""
|
||||
[[ "$MODE" == *"IPv6"* ]] && IPERF_FLAGS="-6" || IPERF_FLAGS="-4"
|
||||
|
||||
# print iperf3 network speed results as they are completed
|
||||
echo -e
|
||||
echo -e "iperf3 Network Speed Tests ($MODE):"
|
||||
echo -e "---------------------------------"
|
||||
printf "%-25s | %-25s | %-15s | %-15s\n" "Provider" "Location (Link)" "Send Speed" "Recv Speed"
|
||||
printf "%-25s | %-25s | %-15s | %-15s\n"
|
||||
|
||||
# loop through iperf locations array to run iperf test using each public iperf server
|
||||
for (( i = 0; i < IPERF_LOCS_NUM; i++ )); do
|
||||
# test if the current iperf location supports the network mode being tested (IPv4/IPv6)
|
||||
if [[ "${IPERF_LOCS[i*5+4]}" == *"$MODE"* ]]; then
|
||||
echo -e "Performing $MODE iperf3 test to ${IPERF_LOCS[i*5+2]}..."
|
||||
iperf_test "${IPERF_LOCS[i*5]}" "${IPERF_LOCS[i*5+1]}" "$IPERF_FLAGS"
|
||||
echo -en "\e[1A"
|
||||
# call the iperf_test function passing the required parameters
|
||||
iperf_test "${IPERF_LOCS[i*5]}" "${IPERF_LOCS[i*5+1]}" "${IPERF_LOCS[i*5+2]}" "$IPERF_FLAGS"
|
||||
# parse the send and recieve speed results
|
||||
IPERF_SENDRESULT_VAL=$(echo $IPERF_SENDRESULT | awk '{ print $6 }')
|
||||
IPERF_SENDRESULT_UNIT=$(echo $IPERF_SENDRESULT | awk '{ print $7 }')
|
||||
IPERF_RECVRESULT_VAL=$(echo $IPERF_RECVRESULT | awk '{ print $6 }')
|
||||
IPERF_RECVRESULT_UNIT=$(echo $IPERF_RECVRESULT | awk '{ print $7 }')
|
||||
[ -z "$IPERF_SENDRESULT_VAL" ] && IPERF_SENDRESULT_VAL="busy"
|
||||
[ -z "$IPERF_RECVRESULT_VAL" ] && IPERF_RECVRESULT_VAL="busy"
|
||||
# if the results are blank, then the server is "busy" and being overutilized
|
||||
[[ -z $IPERF_SENDRESULT_VAL || "$IPERF_SENDRESULT_VAL" == *"0.00"* ]] && IPERF_SENDRESULT_VAL="busy"
|
||||
[[ -z $IPERF_RECVRESULT_VAL || "$IPERF_RECVRESULT_VAL" == *"0.00"* ]] && IPERF_RECVRESULT_VAL="busy"
|
||||
# print the speed results for the iperf location currently being evaluated
|
||||
printf "%-25s | %-25s | %-15s | %-15s\n" "${IPERF_LOCS[i*5+2]}" "${IPERF_LOCS[i*5+3]}" "$IPERF_SENDRESULT_VAL $IPERF_SENDRESULT_UNIT" "$IPERF_RECVRESULT_VAL $IPERF_RECVRESULT_UNIT"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# if the skip iperf flag was set, skip the network performance test, otherwise test network performance
|
||||
if [ -z "$SKIP_IPERF" ]; then
|
||||
# create a temp directory to house the required iperf binary and library
|
||||
IPERF_PATH=$YABS_PATH/iperf
|
||||
mkdir -p $IPERF_PATH
|
||||
# download the publicly available iperf files from project's official source (iperf.fr)
|
||||
curl -s -o $IPERF_PATH/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3 > /dev/null
|
||||
curl -s -o $IPERF_PATH/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3 > /dev/null
|
||||
chmod +x $IPERF_PATH/iperf3
|
||||
|
||||
# test if the host has IPv4/IPv6 connectivity
|
||||
IPV4_CHECK=$(curl -s -4 -m 4 icanhazip.com 2> /dev/null)
|
||||
IPV6_CHECK=$(curl -s -6 -m 4 icanhazip.com 2> /dev/null)
|
||||
|
||||
# array containing all currently available iperf3 public servers to use for the network test
|
||||
# format: "1" "2" "3" "4" "5" \
|
||||
# 1. domain name of the iperf server
|
||||
# 2. range of ports that the iperf server is running on (lowest-highest)
|
||||
# 3. friendly name of the host/owner of the iperf server
|
||||
# 4. location and advertised speed link of the iperf server
|
||||
# 5. network modes supported by the iperf server (IPv4 = IPv4-only, IPv4|IPv6 = IPv4 + IPv6, etc.)
|
||||
IPERF_LOCS=( \
|
||||
"bouygues.iperf.fr" "5200-5209" "Bouygues Telecom" "Paris, FR (10G)" "IPv4|IPv6" \
|
||||
"ping.online.net" "5200-5209" "Online.net" "Paris, FR (10G)" "IPv4" \
|
||||
@ -191,43 +283,65 @@ if [ -z "$SKIP_IPERF" ]; then
|
||||
"speedtest.wtnet.de" "5200-5209" "wilhelm.tel" "Hamburg, DE (10G)" "IPv4|IPv6" \
|
||||
"iperf.biznetnetworks.com" "5201-5203" "Biznet" "Bogor, Indonesia (1G)" "IPv4" \
|
||||
"speedtest.hostkey.ru" "5200-5203" "Hostkey" "Moscow, RU (1G)" "IPv4" \
|
||||
"mirror.square-r00t.net" "5201-5201" "Vultr" "Piscataway, NJ, US (1G)" "IPv4|IPv6" \
|
||||
"iperf3.velocityonline.net" "5201-5210" "Velocity Online" "Tallahassee, FL, US (10G)" "IPv4" \
|
||||
"iperf.airstreamcomm.net" "5201-5205" "Airstream Communications" "Eau Claire, WI, US (10G)" "IPv4|IPv6" \
|
||||
"iperf.he.net" "5201-5201" "Hurricane Electric" "Fremont, CA, US (10G)" "IPv4|IPv6" \
|
||||
)
|
||||
|
||||
# get the total number of iperf locations (total array size divided by 5 since each location has 5 elements)
|
||||
IPERF_LOCS_NUM=${#IPERF_LOCS[@]}
|
||||
IPERF_LOCS_NUM=$((IPERF_LOCS_NUM / 5))
|
||||
|
||||
[ ! -z "$IPV4_CHECK" ] && launch_iperf "IPv4" "-4"
|
||||
[ ! -z "$IPV6_CHECK" ] && launch_iperf "IPv6" "-6"
|
||||
# check if the host has IPv4 connectivity, if so, run iperf3 IPv4 tests
|
||||
[ ! -z "$IPV4_CHECK" ] && launch_iperf "IPv4"
|
||||
# check if the host has IPv6 connectivity, if so, run iperf3 IPv6 tests
|
||||
[ ! -z "$IPV6_CHECK" ] && launch_iperf "IPv6"
|
||||
fi
|
||||
|
||||
# if the skip geekbench flag was set, skip the system performance test, otherwise test system performance
|
||||
if [ -z "$SKIP_GEEKBENCH" ]; then
|
||||
echo -e "Performing Geekbench 4 benchmark test. This may take a couple minutes to complete..."
|
||||
|
||||
echo -en "\nPerforming Geekbench 4 benchmark test. This may take a couple minutes to complete..."
|
||||
|
||||
# create a temp directory to house all geekbench files
|
||||
GEEKBENCH_PATH=$YABS_PATH/geekbench
|
||||
mkdir -p $GEEKBENCH_PATH
|
||||
curl -s http://cdn.geekbench.com/Geekbench-4.3.3-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH
|
||||
GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench4 | grep "https://browser")
|
||||
GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1)
|
||||
GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }')
|
||||
GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }')
|
||||
sleep 10
|
||||
GEEKBENCH_SCORES=$(curl -s $GEEKBENCH_URL | grep "class='score' rowspan")
|
||||
GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }')
|
||||
GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(<|>)" '{ print $7 }')
|
||||
# download the latest Geekbench 4 tarball and extract to geekbench temp directory
|
||||
curl -s http://cdn.geekbench.com/Geekbench-4.3.3-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null
|
||||
# run the Geekbench 4 test and grep the test results URL given at the end of the test
|
||||
GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench4 2>/dev/null | grep "https://browser")
|
||||
|
||||
# ensure the test ran successfully
|
||||
if [ -z "$GEEKBENCH_TEST" ]; then
|
||||
# if the Geekbench 4 test failed for any reason, exit cleanly and print error message
|
||||
echo -e "\r\033[0KGeekbench 4 test failed. Run manually to determine cause."
|
||||
else
|
||||
# if the Geekbench 4 test succeeded, parse the test results URL
|
||||
GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1)
|
||||
GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }')
|
||||
GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }')
|
||||
# sleep a bit to wait for results to be made available on the geekbench website
|
||||
sleep 10
|
||||
# parse the public results page for the single and multi core geekench scores
|
||||
GEEKBENCH_SCORES=$(curl -s $GEEKBENCH_URL | grep "class='score' rowspan")
|
||||
GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }')
|
||||
GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(<|>)" '{ print $7 }')
|
||||
|
||||
echo -en "\e[1A"; echo -e "\e[0K\r"
|
||||
echo -e "Geekbench 4 Benchmark Test:"
|
||||
echo -e "---------------------------------"
|
||||
printf "%-15s | %-30s\n" "Test" "Value"
|
||||
printf "%-15s | %-30s\n"
|
||||
printf "%-15s | %-30s\n" "Single Core" "$GEEKBENCH_SCORES_SINGLE"
|
||||
printf "%-15s | %-30s\n" "Multi Core" "$GEEKBENCH_SCORES_MULTI"
|
||||
printf "%-15s | %-30s\n" "Full Test" "$GEEKBENCH_URL"
|
||||
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" > geekbench4_claim.url 2> /dev/null
|
||||
# print the Geekbench 4 results
|
||||
echo -en "\r\033[0K"
|
||||
echo -e "Geekbench 4 Benchmark Test:"
|
||||
echo -e "---------------------------------"
|
||||
printf "%-15s | %-30s\n" "Test" "Value"
|
||||
printf "%-15s | %-30s\n"
|
||||
printf "%-15s | %-30s\n" "Single Core" "$GEEKBENCH_SCORES_SINGLE"
|
||||
printf "%-15s | %-30s\n" "Multi Core" "$GEEKBENCH_SCORES_MULTI"
|
||||
printf "%-15s | %-30s\n" "Full Test" "$GEEKBENCH_URL"
|
||||
|
||||
# write the geekbench 4 claim URL to a file so the user can add the results to their profile (if desired)
|
||||
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" > geekbench4_claim.url 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# finished all tests, clean up all YABS files and exit
|
||||
echo -e
|
||||
rm -rf $YABS_PATH
|
||||
|
Loading…
x
Reference in New Issue
Block a user