12
12
# performance via fio. The script is designed to not require any dependencies
13
13
# - either compiled or installed - nor admin privileges to run.
14
14
15
- YABS_VERSION=" v2024-12-17 "
15
+ YABS_VERSION=" v2024-12-20 "
16
16
17
17
echo -e ' # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
18
18
echo -e ' # Yet-Another-Bench-Script #'
@@ -436,11 +436,11 @@ function format_iops {
436
436
# divide the raw result by 1k
437
437
RESULT=$( awk -v a=" $RESULT " ' BEGIN { print a / 1000 }' )
438
438
# shorten the formatted result to one decimal place (i.e. x.x)
439
- RESULT=$( echo $RESULT | awk -F. ' { printf "%0.1f",$1"."substr($2,1,1) }' )
439
+ RESULT=$( echo " $RESULT " | awk -F. ' { printf "%0.1f",$1"."substr($2,1,1) }' )
440
440
RESULT=" $RESULT " k
441
441
fi
442
442
443
- echo $RESULT
443
+ echo " $RESULT "
444
444
}
445
445
446
446
# disk_test
@@ -541,7 +541,7 @@ elif [ -z "$SKIP_FIO" ]; then
541
541
542
542
for pathls in $( df -Th | awk ' {print $7}' | tail -n +2)
543
543
do
544
- if [[ " ${PWD## $pathls } " != " $PWD " ]]; then
544
+ if [[ " ${PWD## " $pathls " } " != " $PWD " ]]; then
545
545
poss+=(" $pathls " )
546
546
fi
547
547
done
@@ -564,7 +564,7 @@ elif [ -z "$SKIP_FIO" ]; then
564
564
size_b=' G'
565
565
fi
566
566
567
- if [[ $( df -Th | grep -w $long ) == * " zfs" * ]]; then
567
+ if [[ $( df -Th | grep -w " $long " ) == * " zfs" * ]]; then
568
568
569
569
if [[ $size_b == ' G' ]]; then
570
570
if (( free_space < mul_spa)) ; then
@@ -627,13 +627,13 @@ elif [ -z "$SKIP_FIO" ]; then
627
627
dd_test
628
628
629
629
# format the speed averages by converting to GB/s if > 1000 MB/s
630
- if [ $( echo $DISK_WRITE_TEST_AVG | cut -d " ." -f 1) -ge 1000 ]; then
630
+ if [ " $( echo " $DISK_WRITE_TEST_AVG " | cut -d " ." -f 1) " -ge 1000 ]; then
631
631
DISK_WRITE_TEST_AVG=$( awk -v a=" $DISK_WRITE_TEST_AVG " ' BEGIN { print a / 1000 }' )
632
632
DISK_WRITE_TEST_UNIT=" GB/s"
633
633
else
634
634
DISK_WRITE_TEST_UNIT=" MB/s"
635
635
fi
636
- if [ $( echo $DISK_READ_TEST_AVG | cut -d " ." -f 1) -ge 1000 ]; then
636
+ if [ " $( echo " $DISK_READ_TEST_AVG " | cut -d " ." -f 1) " -ge 1000 ]; then
637
637
DISK_READ_TEST_AVG=$( awk -v a=" $DISK_READ_TEST_AVG " ' BEGIN { print a / 1000 }' )
638
638
DISK_READ_TEST_UNIT=" GB/s"
639
639
else
@@ -645,21 +645,21 @@ elif [ -z "$SKIP_FIO" ]; then
645
645
echo -e " dd Sequential Disk Speed Tests:"
646
646
echo -e " ---------------------------------"
647
647
printf " %-6s | %-6s %-4s | %-6s %-4s | %-6s %-4s | %-6s %-4s\n" " " " Test 1" " " " Test 2" " " " Test 3" " " " Avg" " "
648
- printf " %-6s | %-6s %-4s | %-6s %-4s | %-6s %-4s | %-6s %-4s\n"
648
+ printf " %-6s | %-6s %-4s | %-6s %-4s | %-6s %-4s | %-6s %-4s\n" " " " " " " " " " " " " " " " " " "
649
649
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} "
650
650
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} "
651
651
else # fio tests completed successfully, print results
652
652
CURRENT_PARTITION=$( df -P . 2> /dev/null | tail -1 | cut -d' ' -f 1)
653
653
[[ -n $JSON ]] && JSON_RESULT+=' ,"partition":"' $CURRENT_PARTITION ' ","fio":['
654
- DISK_RESULTS_NUM=$( expr ${# DISK_RESULTS[@]} / 6)
654
+ DISK_RESULTS_NUM=$(( ${# DISK_RESULTS[@]} / 6 ) )
655
655
DISK_COUNT=0
656
656
657
657
# print disk speed test results
658
658
echo -e " fio Disk Speed Tests (Mixed R/W 50/50) (Partition $CURRENT_PARTITION ):"
659
659
echo -e " ---------------------------------"
660
660
661
- while [ $DISK_COUNT -lt $DISK_RESULTS_NUM ] ; do
662
- if [ $DISK_COUNT -gt 0 ]; then printf " %-10s | %-20s | %-20s\n" ; fi
661
+ while [[ $DISK_COUNT -lt $DISK_RESULTS_NUM ] ] ; do
662
+ if [[ $DISK_COUNT -gt 0 ]] ; then printf " %-10s | %-20s | %-20s\n" " " " " " " ; fi
663
663
printf " %-10s | %-11s %8s | %-11s %8s\n" " Block Size" " ${BLOCK_SIZES[DISK_COUNT]} " " (IOPS)" " ${BLOCK_SIZES[DISK_COUNT+1]} " " (IOPS)"
664
664
printf " %-10s | %-11s %8s | %-11s %8s\n" " ------" " ---" " ---- " " ----" " ---- "
665
665
printf " %-10s | %-11s %8s | %-11s %8s\n" " Read" " ${DISK_RESULTS[DISK_COUNT*6+1]} " " (${DISK_RESULTS[DISK_COUNT*6+4]} )" " ${DISK_RESULTS[(DISK_COUNT+1)*6+1]} " " (${DISK_RESULTS[(DISK_COUNT+1)*6+4]} )"
@@ -673,7 +673,7 @@ elif [ -z "$SKIP_FIO" ]; then
673
673
JSON_RESULT+=' ,"speed_w":' ${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+2]} ' ,"iops_w":' ${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+5]} ' ,"speed_rw":' ${DISK_RESULTS_RAW[(DISK_COUNT+1)*6]}
674
674
JSON_RESULT+=' ,"iops_rw":' ${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+3]} ' ,"speed_units":"KBps"},'
675
675
fi
676
- DISK_COUNT=$( expr $DISK_COUNT + 2)
676
+ DISK_COUNT=$(( $DISK_COUNT + 2 ) )
677
677
done
678
678
[[ -n $JSON ]] && JSON_RESULT=${JSON_RESULT:: ${# JSON_RESULT} -1} && JSON_RESULT+=' ]'
679
679
fi
@@ -701,20 +701,20 @@ function iperf_test {
701
701
do
702
702
echo -en " Performing $MODE iperf3 send test to $HOST (Attempt #$I of 3)..."
703
703
# select a random iperf port from the range provided
704
- PORT=$( shuf -i $PORTS -n 1)
704
+ PORT=$( shuf -i " $PORTS " -n 1)
705
705
# run the iperf test sending data from the host to the iperf server; includes
706
706
# a timeout of 15s in case the iperf server is not responding; uses 8 parallel
707
707
# threads for the network test
708
- IPERF_RUN_SEND=" $( timeout 15 $IPERF_CMD $FLAGS -c " $URL " -p $PORT -P 8 2> /dev/null) "
708
+ IPERF_RUN_SEND=" $( timeout 15 " $IPERF_CMD " " $FLAGS " -c " $URL " -p " $PORT " -P 8 2> /dev/null) "
709
709
# check if iperf exited cleanly and did not return an error
710
710
if [[ " $IPERF_RUN_SEND " == * " receiver" * && " $IPERF_RUN_SEND " != * " error" * ]]; then
711
711
# test did not result in an error, parse speed result
712
712
SPEED=$( echo " ${IPERF_RUN_SEND} " | grep SUM | grep receiver | awk ' { print $6 }' )
713
713
# if speed result is blank or bad (0.00), rerun, otherwise set counter to exit loop
714
- [[ -z $SPEED || " $SPEED " == " 0.00" ]] && I=$(( $ I + 1 )) || I=11
714
+ [[ -z $SPEED || " $SPEED " == " 0.00" ]] && I=$(( I + 1 )) || I=11
715
715
else
716
716
# if iperf server is not responding, set counter to exit, otherwise increment, sleep, and rerun
717
- [[ " $IPERF_RUN_SEND " == * " unable to connect" * ]] && I=11 || I=$(( $ I + 1 )) && sleep 2
717
+ [[ " $IPERF_RUN_SEND " == * " unable to connect" * ]] && I=11 || I=$(( I + 1 )) && sleep 2
718
718
fi
719
719
echo -en " \r\033[0K"
720
720
done
@@ -729,32 +729,32 @@ function iperf_test {
729
729
do
730
730
echo -n " Performing $MODE iperf3 recv test from $HOST (Attempt #$J of 3)..."
731
731
# select a random iperf port from the range provided
732
- PORT=$( shuf -i $PORTS -n 1)
732
+ PORT=$( shuf -i " $PORTS " -n 1)
733
733
# run the iperf test receiving data from the iperf server to the host; includes
734
734
# a timeout of 15s in case the iperf server is not responding; uses 8 parallel
735
735
# threads for the network test
736
- IPERF_RUN_RECV=" $( timeout 15 $IPERF_CMD $FLAGS -c " $URL " -p $PORT -P 8 -R 2> /dev/null) "
736
+ IPERF_RUN_RECV=" $( timeout 15 " $IPERF_CMD " " $FLAGS " -c " $URL " -p " $PORT " -P 8 -R 2> /dev/null) "
737
737
# check if iperf exited cleanly and did not return an error
738
738
if [[ " $IPERF_RUN_RECV " == * " receiver" * && " $IPERF_RUN_RECV " != * " error" * ]]; then
739
739
# test did not result in an error, parse speed result
740
740
SPEED=$( echo " ${IPERF_RUN_RECV} " | grep SUM | grep receiver | awk ' { print $6 }' )
741
741
# if speed result is blank or bad (0.00), rerun, otherwise set counter to exit loop
742
- [[ -z $SPEED || " $SPEED " == " 0.00" ]] && J=$(( $ J + 1 )) || J=11
742
+ [[ -z $SPEED || " $SPEED " == " 0.00" ]] && J=$(( J + 1 )) || J=11
743
743
else
744
744
# if iperf server is not responding, set counter to exit, otherwise increment, sleep, and rerun
745
- [[ " $IPERF_RUN_RECV " == * " unable to connect" * ]] && J=11 || J=$(( $ J + 1 )) && sleep 2
745
+ [[ " $IPERF_RUN_RECV " == * " unable to connect" * ]] && J=11 || J=$(( J + 1 )) && sleep 2
746
746
fi
747
747
echo -en " \r\033[0K"
748
748
done
749
749
750
750
# Run a latency test via ping -c1 command -> will return "xx.x ms"
751
- [[ -n $LOCAL_PING ]] && LATENCY_RUN=" $( ping -c1 $URL 2> /dev/null | grep -o ' time=.*' | sed s/' time=' //) "
751
+ [[ -n $LOCAL_PING ]] && LATENCY_RUN=" $( ping -c1 " $URL " 2> /dev/null | grep -o ' time=.*' | sed s/' time=' //) "
752
752
[[ -z $LATENCY_RUN ]] && LATENCY_RUN=" --"
753
753
754
754
# parse the resulting send and receive speed results
755
755
IPERF_SENDRESULT=" $( echo " ${IPERF_RUN_SEND} " | grep SUM | grep receiver) "
756
756
IPERF_RECVRESULT=" $( echo " ${IPERF_RUN_RECV} " | grep SUM | grep receiver) "
757
- LATENCY_RESULT=" $( echo " $ {LATENCY_RUN}" ) "
757
+ LATENCY_RESULT=" ${LATENCY_RUN} "
758
758
}
759
759
760
760
# launch_iperf
@@ -780,11 +780,11 @@ function launch_iperf {
780
780
# call the iperf_test function passing the required parameters
781
781
iperf_test " ${IPERF_LOCS[i*5]} " " ${IPERF_LOCS[i*5+1]} " " ${IPERF_LOCS[i*5+2]} " " $IPERF_FLAGS "
782
782
# parse the send and receive speed results
783
- IPERF_SENDRESULT_VAL=$( echo $IPERF_SENDRESULT | awk ' { print $6 }' )
784
- IPERF_SENDRESULT_UNIT=$( echo $IPERF_SENDRESULT | awk ' { print $7 }' )
785
- IPERF_RECVRESULT_VAL=$( echo $IPERF_RECVRESULT | awk ' { print $6 }' )
786
- IPERF_RECVRESULT_UNIT=$( echo $IPERF_RECVRESULT | awk ' { print $7 }' )
787
- LATENCY_VAL=$( echo $ LATENCY_RESULT)
783
+ IPERF_SENDRESULT_VAL=$( echo " $IPERF_SENDRESULT " | awk ' { print $6 }' )
784
+ IPERF_SENDRESULT_UNIT=$( echo " $IPERF_SENDRESULT " | awk ' { print $7 }' )
785
+ IPERF_RECVRESULT_VAL=$( echo " $IPERF_RECVRESULT " | awk ' { print $6 }' )
786
+ IPERF_RECVRESULT_UNIT=$( echo " $IPERF_RECVRESULT " | awk ' { print $7 }' )
787
+ LATENCY_VAL=" ${ LATENCY_RESULT} "
788
788
# if the results are blank, then the server is "busy" and being overutilized
789
789
[[ -z $IPERF_SENDRESULT_VAL || " $IPERF_SENDRESULT_VAL " == * " 0.00" * ]] && IPERF_SENDRESULT_VAL=" busy" && IPERF_SENDRESULT_UNIT=" "
790
790
[[ -z $IPERF_RECVRESULT_VAL || " $IPERF_RECVRESULT_VAL " == * " 0.00" * ]] && IPERF_RECVRESULT_VAL=" busy" && IPERF_RECVRESULT_UNIT=" "
@@ -924,7 +924,7 @@ function launch_geekbench {
924
924
fi
925
925
926
926
# unlock if license file detected
927
- test -f " geekbench.license" && " $GEEKBENCH_PATH /$GB_CMD " --unlock $( cat geekbench.license) > /dev/null 2>&1
927
+ test -f " geekbench.license" && " $GEEKBENCH_PATH /$GB_CMD " --unlock " $( cat geekbench.license) " > /dev/null 2>&1
928
928
929
929
# run the Geekbench test and grep the test results URL given at the end of the test
930
930
GEEKBENCH_TEST=$( " $GEEKBENCH_PATH /$GB_CMD " --upload 2> /dev/null | grep " https://browser" )
@@ -947,24 +947,24 @@ function launch_geekbench {
947
947
fi
948
948
else
949
949
# if the Geekbench test succeeded, parse the test results URL
950
- GEEKBENCH_URL=$( echo -e $GEEKBENCH_TEST | head -1)
951
- GEEKBENCH_URL_CLAIM=$( echo $GEEKBENCH_URL | awk ' { print $2 }' )
952
- GEEKBENCH_URL=$( echo $GEEKBENCH_URL | awk ' { print $1 }' )
950
+ GEEKBENCH_URL=$( echo -e " $GEEKBENCH_TEST " | head -1)
951
+ GEEKBENCH_URL_CLAIM=$( echo " $GEEKBENCH_URL " | awk ' { print $2 }' )
952
+ GEEKBENCH_URL=$( echo " $GEEKBENCH_URL " | awk ' { print $1 }' )
953
953
# sleep a bit to wait for results to be made available on the geekbench website
954
954
sleep 10
955
955
# parse the public results page for the single and multi core geekbench scores
956
- [[ $VERSION == * 4* ]] && GEEKBENCH_SCORES=$( $DL_CMD $GEEKBENCH_URL | grep " span class='score'" ) || \
957
- GEEKBENCH_SCORES=$( $DL_CMD $GEEKBENCH_URL | grep " div class='score'" )
956
+ [[ $VERSION == * 4* ]] && GEEKBENCH_SCORES=$( $DL_CMD " $GEEKBENCH_URL " | grep " span class='score'" ) || \
957
+ GEEKBENCH_SCORES=$( $DL_CMD " $GEEKBENCH_URL " | grep " div class='score'" )
958
958
959
- GEEKBENCH_SCORES_SINGLE=$( echo $GEEKBENCH_SCORES | awk -v FS=" (>|<)" ' { print $3 }' )
960
- GEEKBENCH_SCORES_MULTI=$( echo $GEEKBENCH_SCORES | awk -v FS=" (>|<)" ' { print $7 }' )
959
+ GEEKBENCH_SCORES_SINGLE=$( echo " $GEEKBENCH_SCORES " | awk -v FS=" (>|<)" ' { print $3 }' )
960
+ GEEKBENCH_SCORES_MULTI=$( echo " $GEEKBENCH_SCORES " | awk -v FS=" (>|<)" ' { print $7 }' )
961
961
962
962
# print the Geekbench results
963
963
echo -en " \r\033[0K"
964
964
echo -e " Geekbench $VERSION Benchmark Test:"
965
965
echo -e " ---------------------------------"
966
966
printf " %-15s | %-30s\n" " Test" " Value"
967
- printf " %-15s | %-30s\n"
967
+ printf " %-15s | %-30s\n" " " " "
968
968
printf " %-15s | %-30s\n" " Single Core" " $GEEKBENCH_SCORES_SINGLE "
969
969
printf " %-15s | %-30s\n" " Multi Core" " $GEEKBENCH_SCORES_MULTI "
970
970
printf " %-15s | %-30s\n" " Full Test" " $GEEKBENCH_URL "
@@ -982,7 +982,7 @@ function launch_geekbench {
982
982
983
983
# if the skip geekbench flag was set, skip the system performance test, otherwise test system performance
984
984
if [ -z " $SKIP_GEEKBENCH " ]; then
985
- [[ -n $JSON ]] && JSON_RESULT+=' , "geekbench":['
985
+ [[ -n $JSON ]] && JSON_RESULT+=( " , \ " geekbench\ " :[" )
986
986
if [[ $GEEKBENCH_4 == * True* ]]; then
987
987
launch_geekbench 4
988
988
fi
@@ -994,7 +994,7 @@ if [ -z "$SKIP_GEEKBENCH" ]; then
994
994
if [[ $GEEKBENCH_6 == * True* ]]; then
995
995
launch_geekbench 6
996
996
fi
997
- [[ -n $JSON ]] && [[ $( echo -n $ JSON_RESULT | tail -c 1 ) == ' ,' ]] && JSON_RESULT=${JSON_RESULT :: ${ # JSON_RESULT} -1}
997
+ [[ -n $JSON ]] && [[ " ${ JSON_RESULT: -1} " == ' ,' ]] && JSON_RESULT=$( echo " $ JSON_RESULT" | sed ' s/,$// ' )
998
998
[[ -n $JSON ]] && JSON_RESULT+=' ]'
999
999
fi
1000
1000
@@ -1013,25 +1013,25 @@ function calculate_time_taken() {
1013
1013
end_time=$1
1014
1014
start_time=$2
1015
1015
1016
- time_taken=$(( ${ end_time} - ${ start_time} ))
1016
+ time_taken=$(( end_time - start_time ))
1017
1017
if [ ${time_taken} -gt 60 ]; then
1018
- min=$( expr $ time_taken / 60)
1019
- sec=$( expr $ time_taken % 60)
1018
+ min=$(( time_taken / 60 ) )
1019
+ sec=$(( time_taken % 60 ) )
1020
1020
echo " YABS completed in ${min} min ${sec} sec"
1021
1021
else
1022
1022
echo " YABS completed in ${time_taken} sec"
1023
1023
fi
1024
1024
[[ -n $JSON ]] && JSON_RESULT+=' ,"runtime":{"start":' $start_time ' ,"end":' $end_time ' ,"elapsed":' $time_taken ' }'
1025
1025
}
1026
1026
1027
- calculate_time_taken $YABS_END_TIME $YABS_START_TIME
1027
+ calculate_time_taken " $YABS_END_TIME " " $YABS_START_TIME "
1028
1028
1029
1029
if [[ -n $JSON ]]; then
1030
1030
JSON_RESULT+=' }'
1031
1031
1032
1032
# write json results to file
1033
1033
if [[ $JSON = * w* ]]; then
1034
- echo $JSON_RESULT > " $JSON_FILE "
1034
+ echo " $JSON_RESULT " > " $JSON_FILE "
1035
1035
fi
1036
1036
1037
1037
# send json results
@@ -1040,17 +1040,17 @@ if [[ -n $JSON ]]; then
1040
1040
for JSON_SITE in " ${JSON_SITES[@]} "
1041
1041
do
1042
1042
if [[ -n $LOCAL_CURL ]]; then
1043
- curl -s -H " Content-Type:application/json" -X POST --data ' ' " $JSON_RESULT " ' ' $JSON_SITE
1043
+ curl -s -H " Content-Type:application/json" -X POST --data ' ' " $JSON_RESULT " ' ' " $JSON_SITE "
1044
1044
else
1045
- wget -qO- --post-data=' ' " $JSON_RESULT " ' ' --header=' Content-Type:application/json' $JSON_SITE
1045
+ wget -qO- --post-data=' ' " $JSON_RESULT " ' ' --header=' Content-Type:application/json' " $JSON_SITE "
1046
1046
fi
1047
1047
done
1048
1048
fi
1049
1049
1050
1050
# print json result to screen
1051
1051
if [[ $JSON = * j* ]]; then
1052
1052
echo -e
1053
- echo $JSON_RESULT
1053
+ echo " $JSON_RESULT "
1054
1054
fi
1055
1055
fi
1056
1056
0 commit comments