2019-10-03 08:48:33 +07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
|
|
|
echo -e '# Yet-Another-Bench-Script #'
|
2019-10-05 08:14:41 +07:00
|
|
|
echo -e '# v2019-10-04 #'
|
2019-10-03 08:48:33 +07:00
|
|
|
echo -e '# https://github.com/masonr/yet-another-bench-script #'
|
|
|
|
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
|
|
|
|
2019-10-03 21:22:58 +07:00
|
|
|
echo -e
|
|
|
|
date
|
|
|
|
|
|
|
|
echo -e
|
|
|
|
echo -e "Basic System Information:"
|
|
|
|
echo -e "---------------------------------"
|
|
|
|
CPU_PROC=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
2019-10-04 09:33:33 +07:00
|
|
|
echo -e "Processor : $CPU_PROC"
|
2019-10-03 21:22:58 +07:00
|
|
|
CPU_CORES=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)
|
|
|
|
CPU_FREQ=$(awk -F: ' /cpu MHz/ {freq=$2} END {print freq " MHz"}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
2019-10-04 09:33:33 +07:00
|
|
|
echo -e "CPU cores : $CPU_CORES @ $CPU_FREQ"
|
|
|
|
CPU_AES=$(cat /proc/cpuinfo | grep aes)
|
|
|
|
[[ -z "$CPU_AES" ]] && CPU_AES="\xE2\x9D\x8C Disabled" || CPU_AES="\xE2\x9C\x94 Enabled"
|
|
|
|
echo -e "AES-NI : $CPU_AES"
|
|
|
|
CPU_VIRT=$(cat /proc/cpuinfo | grep 'vmx|svm')
|
|
|
|
[[ -z "$CPU_VIRT" ]] && CPU_VIRT="\xE2\x9D\x8C Disabled" || CPU_VIRT="\xE2\x9C\x94 Enabled"
|
|
|
|
echo -e "VM-x/AMD-V : $CPU_VIRT"
|
2019-10-03 21:22:58 +07:00
|
|
|
TOTAL_RAM=$(free -h | awk 'NR==2 {print $2}')
|
2019-10-04 09:33:33 +07:00
|
|
|
echo -e "RAM : $TOTAL_RAM"
|
|
|
|
TOTAL_SWAP=$(free -h | grep Swap | awk '{ print $2 }')
|
|
|
|
echo -e "Swap : $TOTAL_SWAP"
|
2019-10-04 20:44:18 +07:00
|
|
|
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 }')
|
2019-10-04 09:33:33 +07:00
|
|
|
echo -e "Disk : $TOTAL_DISK"
|
2019-10-03 21:22:58 +07:00
|
|
|
|
2019-10-04 09:33:33 +07:00
|
|
|
DATE=`date -Iseconds | sed -e "s/:/_/g"`
|
2019-10-05 08:14:41 +07:00
|
|
|
YABS_PATH=/tmp/$DATE/
|
|
|
|
mkdir -p $YABS_PATH
|
|
|
|
|
|
|
|
echo -e
|
|
|
|
echo -e "dd Disk Speed Tests:"
|
|
|
|
echo -e "---------------------------------"
|
|
|
|
|
|
|
|
function dd_test {
|
|
|
|
I=0
|
|
|
|
DD_WRITE_TEST_RES=()
|
|
|
|
DD_READ_TEST_RES=()
|
|
|
|
DD_WRITE_TEST_AVG=0
|
|
|
|
DD_READ_TEST_AVG=0
|
|
|
|
while [ $I -lt 3 ]
|
|
|
|
do
|
|
|
|
DD_WRITE_TEST=$(dd if=/dev/zero of=$DATE.test bs=64k count=16k oflag=direct |& grep copied | awk '{ print $10 " " $11 }')
|
|
|
|
DD_WRITE_TEST_RES+=( "$DD_WRITE_TEST" )
|
|
|
|
VAL=$(echo $DD_WRITE_TEST | cut -d " " -f 1 | cut -d "." -f 1)
|
|
|
|
DD_WRITE_TEST_AVG=$(( DD_WRITE_TEST_AVG + VAL ))
|
|
|
|
|
|
|
|
DD_READ_TEST=$(dd if=$DATE.test of=/dev/null bs=64k |& grep copied | awk '{ print $10 " " $11 }')
|
|
|
|
DD_READ_TEST_RES+=( "$DD_READ_TEST" )
|
|
|
|
VAL=$(echo $DD_READ_TEST | cut -d " " -f 1 | cut -d "." -f 1)
|
|
|
|
DD_READ_TEST_AVG=$(( DD_READ_TEST_AVG + VAL ))
|
|
|
|
|
|
|
|
I=$(( $I + 1 ))
|
|
|
|
done
|
|
|
|
DD_WRITE_TEST_AVG=$((DD_WRITE_TEST_AVG/3))
|
|
|
|
DD_WRITE_TEST_UNIT=$(echo $DD_WRITE_TEST | awk '{ print $2 }')
|
|
|
|
DD_READ_TEST_AVG=$((DD_READ_TEST_AVG/3))
|
|
|
|
DD_READ_TEST_UNIT=$(echo $DD_READ_TEST | awk '{ print $2 }')
|
|
|
|
}
|
|
|
|
|
|
|
|
touch $DATE.test 2> /dev/null
|
|
|
|
if [ -f "$DATE.test" ]; then
|
|
|
|
dd_test
|
|
|
|
rm $DATE.test
|
|
|
|
printf "%-6s | %-10s | %-10s | %-10s | %-10s\n" " " "Test 1" "Test 2" "Test 3" "Avg"
|
|
|
|
printf "%-6s | %-10s | %-10s | %-10s | %-10s\n"
|
|
|
|
printf "%-6s | %-10s | %-10s | %-10s | %-10s\n" "Write" "${DD_WRITE_TEST_RES[0]}" "${DD_WRITE_TEST_RES[1]}" "${DD_WRITE_TEST_RES[2]}" "${DD_WRITE_TEST_AVG} ${DD_WRITE_TEST_UNIT}"
|
2019-10-05 08:33:58 +07:00
|
|
|
printf "%-6s | %-10s | %-10s | %-10s | %-10s\n" "Read*" "${DD_READ_TEST_RES[0]}" "${DD_READ_TEST_RES[1]}" "${DD_READ_TEST_RES[2]}" "${DD_READ_TEST_AVG} ${DD_READ_TEST_UNIT}"
|
2019-10-05 08:14:41 +07:00
|
|
|
|
|
|
|
else
|
|
|
|
echo -e "You do not have write permission in this directory\nSwitch to a different directory to test disk speed.\nSkipping dd tests."
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
IPERF_PATH=$YABS_PATH/iperf
|
2019-10-03 08:48:33 +07:00
|
|
|
mkdir -p $IPERF_PATH
|
2019-10-04 10:27:00 +07:00
|
|
|
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
|
2019-10-03 08:48:33 +07:00
|
|
|
chmod +x $IPERF_PATH/iperf3
|
|
|
|
|
2019-10-03 09:51:36 +07:00
|
|
|
function iperf_test {
|
|
|
|
URL=$1
|
2019-10-04 09:33:33 +07:00
|
|
|
PORTS=$2
|
2019-10-03 09:51:36 +07:00
|
|
|
|
|
|
|
I=0
|
|
|
|
while [ $I -lt 10 ]
|
|
|
|
do
|
2019-10-04 09:33:33 +07:00
|
|
|
PORT=`shuf -i $PORTS -n 1`
|
|
|
|
IPERF_RUN_SEND="$(LD_LIBRARY_PATH=$IPERF_PATH timeout 15 $IPERF_PATH/iperf3 -c $URL -p $PORT -P 8)"
|
|
|
|
if [[ "$IPERF_RUN_SEND" == *"receiver"* && "$IPERF_RUN_SEND" != *"error"* ]]; then
|
2019-10-04 10:48:43 +07:00
|
|
|
SPEED=$(echo "${IPERF_RUN_SEND}" | grep SUM | grep receiver | awk '{ print $6 }')
|
|
|
|
[[ -z $SPEED || "$SPEED" == "0.00" ]] && I=$(( $I + 1 )) || I=10
|
2019-10-03 09:51:36 +07:00
|
|
|
else
|
2019-10-05 08:14:41 +07:00
|
|
|
[[ "$IPERF_RUN_SEND" == *"unable to connect"* ]] && I=10 || I=$(( $I + 1 ))
|
2019-10-04 10:48:43 +07:00
|
|
|
sleep 2
|
2019-10-03 09:51:36 +07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
J=0
|
|
|
|
while [ $J -lt 10 ]
|
|
|
|
do
|
2019-10-04 09:33:33 +07:00
|
|
|
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)"
|
|
|
|
if [[ "$IPERF_RUN_RECV" == *"receiver"* && "$IPERF_RUN_RECV" != *"error"* ]]; then
|
2019-10-04 10:48:43 +07:00
|
|
|
SPEED=$(echo "${IPERF_RUN_RECV}" | grep SUM | grep receiver | awk '{ print $6 }')
|
|
|
|
[[ -z $SPEED || "$SPEED" == "0.00" ]] && J=$(( $J + 1 )) || J=10
|
2019-10-03 09:51:36 +07:00
|
|
|
else
|
2019-10-05 08:14:41 +07:00
|
|
|
[[ "$IPERF_RUN_RECV" == *"unable to connect"* ]] && J=10 || J=$(( $J + 1 ))
|
2019-10-04 10:48:43 +07:00
|
|
|
sleep 2
|
2019-10-03 09:51:36 +07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
IPERF_SENDRESULT="$(echo "${IPERF_RUN_SEND}" | grep SUM | grep receiver)"
|
|
|
|
IPERF_RECVRESULT="$(echo "${IPERF_RUN_RECV}" | grep SUM | grep receiver)"
|
|
|
|
}
|
|
|
|
|
2019-10-03 10:25:58 +07:00
|
|
|
IPERF_LOCS=( \
|
2019-10-04 09:33:33 +07:00
|
|
|
"bouygues.iperf.fr" "5200-5209" "Bouygues Telecom" "Paris, FR (10G)" \
|
|
|
|
"ping.online.net" "5200-5209" "Online.net" "Paris, FR (10G)" \
|
|
|
|
"speedtest.serverius.net" "5002-5002" "Severius" "The Netherlands (10G)" \
|
|
|
|
"iperf.worldstream.nl" "5201-5201" "Worldstream" "The Netherlands (10G)" \
|
|
|
|
"speedtest.wtnet.de" "5200-5209" "wilhelm.tel" "Hamburg, DE (10G)" \
|
|
|
|
"iperf.biznetnetworks.com" "5201-5203" "Biznet" "Bogor, Indonesia (1G)" \
|
|
|
|
"speedtest.hostkey.ru" "5200-5203" "Hostkey" "Moscow, RU (1G)" \
|
|
|
|
"iperf3.velocityonline.net" "5201-5210" "Velocity Online" "Tallahassee, FL, US (?G)" \
|
|
|
|
"iperf.airstreamcomm.net" "5201-5205" "Airstream Communications" "Eau Claire, WI, US (10G)" \
|
|
|
|
"iperf.he.net" "5201-5201" "Hurricane Electric" "Fremont, CA, US (1G)" \
|
2019-10-03 10:25:58 +07:00
|
|
|
)
|
|
|
|
IPERF_LOCS_NUM=${#IPERF_LOCS[@]}
|
2019-10-04 09:33:33 +07:00
|
|
|
IPERF_LOCS_NUM=$((IPERF_LOCS_NUM / 4))
|
2019-10-03 10:25:58 +07:00
|
|
|
|
2019-10-03 21:22:58 +07:00
|
|
|
echo -e
|
2019-10-05 08:14:41 +07:00
|
|
|
echo -e "iperf3 Network Speed Tests:"
|
2019-10-03 21:22:58 +07:00
|
|
|
echo -e "---------------------------------"
|
|
|
|
printf "%-25s | %-25s | %-15s | %-15s\n" "Provider" "Location (Link)" "Send Speed" "Recv Speed"
|
|
|
|
printf "%-25s | %-25s | %-15s | %-15s\n"
|
|
|
|
|
2019-10-03 10:25:58 +07:00
|
|
|
for (( i = 0; i < IPERF_LOCS_NUM; i++ )); do
|
2019-10-04 09:33:33 +07:00
|
|
|
iperf_test "${IPERF_LOCS[i*4]}" "${IPERF_LOCS[i*4+1]}"
|
2019-10-03 21:22:58 +07:00
|
|
|
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"
|
2019-10-04 09:33:33 +07:00
|
|
|
printf "%-25s | %-25s | %-15s | %-15s\n" "${IPERF_LOCS[i*4+2]}" "${IPERF_LOCS[i*4+3]}" "$IPERF_SENDRESULT_VAL $IPERF_SENDRESULT_UNIT" "$IPERF_RECVRESULT_VAL $IPERF_RECVRESULT_UNIT"
|
2019-10-03 09:51:36 +07:00
|
|
|
done
|
2019-10-03 08:48:33 +07:00
|
|
|
|
2019-10-03 21:22:58 +07:00
|
|
|
echo -e
|
2019-10-03 08:48:33 +07:00
|
|
|
rm -rf /tmp/$DATE
|