@@ -233,7 +233,11 @@ echo -e "---------------------------------"
233233UPTIME=$( uptime | awk -F' ( |,|:)+' ' {d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}' )
234234echo -e " Uptime : $UPTIME "
235235# check for local lscpu installs
236- command -v lscpu > /dev/null 2>&1 && LOCAL_LSCPU=true || unset LOCAL_LSCPU
236+ if command -v lscpu > /dev/null 2>&1 ; then
237+ LOCAL_LSCPU=true
238+ else
239+ unset LOCAL_LSCPU
240+ fi
237241if [[ $ARCH = * aarch64* || $ARCH = * arm* ]] && [[ -n $LOCAL_LSCPU ]]; then
238242 CPU_PROC=$( lscpu | grep " Model name" | sed ' s/Model name: *//g' )
239243else
@@ -405,10 +409,10 @@ function format_speed {
405409 # divide the raw result to get the corresponding formatted result (based on determined unit)
406410 RESULT=$( awk -v a=" $RESULT " -v b=" $DENOM " ' BEGIN { print a / b }' )
407411 # shorten the formatted result to two decimal places (i.e. x.xx)
408- RESULT=$( echo $RESULT | awk -F. ' { printf "%0.2f",$1"."substr($2,1,2) }' )
412+ RESULT=$( echo " $RESULT " | awk -F. ' { printf "%0.2f",$1"."substr($2,1,2) }' )
409413 # concat formatted result value with units and return result
410414 RESULT=" $RESULT $UNIT "
411- echo $RESULT
415+ echo " $RESULT "
412416}
413417
414418# format_iops
@@ -462,21 +466,21 @@ function disk_test {
462466 for BS in " ${BLOCK_SIZES[@]} " ; do
463467 # run rand read/write mixed fio test with block size = $BS
464468 echo -en " Running fio random mixed R+W disk test with $BS block size..."
465- DISK_TEST=$( timeout 35 $FIO_CMD --name=rand_rw_$BS --ioengine=libaio --rw=randrw --rwmixread=50 --bs=$BS --iodepth=64 --numjobs=2 --size=$FIO_SIZE --runtime=30 --gtod_reduce=1 --direct=1 --filename=" $DISK_PATH /test.fio" --group_reporting --minimal 2> /dev/null | grep rand_rw_$BS )
466- DISK_IOPS_R=$( echo $DISK_TEST | awk -F' ;' ' {print $8}' )
467- DISK_IOPS_W=$( echo $DISK_TEST | awk -F' ;' ' {print $49}' )
469+ DISK_TEST=$( timeout 35 " $FIO_CMD " --name=rand_rw_" $BS " --ioengine=libaio --rw=randrw --rwmixread=50 --bs=" $BS " --iodepth=64 --numjobs=2 --size=" $FIO_SIZE " --runtime=30 --gtod_reduce=1 --direct=1 --filename=" $DISK_PATH /test.fio" --group_reporting --minimal 2> /dev/null | grep rand_rw_" $BS " )
470+ DISK_IOPS_R=$( echo " $DISK_TEST " | awk -F' ;' ' {print $8}' )
471+ DISK_IOPS_W=$( echo " $DISK_TEST " | awk -F' ;' ' {print $49}' )
468472 DISK_IOPS=$( awk -v a=" $DISK_IOPS_R " -v b=" $DISK_IOPS_W " ' BEGIN { print a + b }' )
469- DISK_TEST_R=$( echo $DISK_TEST | awk -F' ;' ' {print $7}' )
470- DISK_TEST_W=$( echo $DISK_TEST | awk -F' ;' ' {print $48}' )
473+ DISK_TEST_R=$( echo " $DISK_TEST " | awk -F' ;' ' {print $7}' )
474+ DISK_TEST_W=$( echo " $DISK_TEST " | awk -F' ;' ' {print $48}' )
471475 DISK_TEST=$( awk -v a=" $DISK_TEST_R " -v b=" $DISK_TEST_W " ' BEGIN { print a + b }' )
472476 DISK_RESULTS_RAW+=( " $DISK_TEST " " $DISK_TEST_R " " $DISK_TEST_W " " $DISK_IOPS " " $DISK_IOPS_R " " $DISK_IOPS_W " )
473477
474- DISK_IOPS=$( format_iops $DISK_IOPS )
475- DISK_IOPS_R=$( format_iops $DISK_IOPS_R )
476- DISK_IOPS_W=$( format_iops $DISK_IOPS_W )
477- DISK_TEST=$( format_speed $DISK_TEST )
478- DISK_TEST_R=$( format_speed $DISK_TEST_R )
479- DISK_TEST_W=$( format_speed $DISK_TEST_W )
478+ DISK_IOPS=$( format_iops " $DISK_IOPS " )
479+ DISK_IOPS_R=$( format_iops " $DISK_IOPS_R " )
480+ DISK_IOPS_W=$( format_iops " $DISK_IOPS_W " )
481+ DISK_TEST=$( format_speed " $DISK_TEST " )
482+ DISK_TEST_R=$( format_speed " $DISK_TEST_R " )
483+ DISK_TEST_W=$( format_speed " $DISK_TEST_W " )
480484
481485 DISK_RESULTS+=( " $DISK_TEST " " $DISK_TEST_R " " $DISK_TEST_W " " $DISK_IOPS " " $DISK_IOPS_R " " $DISK_IOPS_W " )
482486 echo -en " \r\033[0K"
@@ -501,19 +505,19 @@ function dd_test {
501505 do
502506 # write test using dd, "direct" flag is used to test direct I/O for data being stored to disk
503507 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)}' )
504- VAL=$( echo $DISK_WRITE_TEST | cut -d " " -f 1)
508+ VAL=$( echo " $DISK_WRITE_TEST " | cut -d " " -f 1)
505509 [[ " $DISK_WRITE_TEST " == * " GB" * ]] && VAL=$( awk -v a=" $VAL " ' BEGIN { print a * 1000 }' )
506510 DISK_WRITE_TEST_RES+=( " $DISK_WRITE_TEST " )
507511 DISK_WRITE_TEST_AVG=$( awk -v a=" $DISK_WRITE_TEST_AVG " -v b=" $VAL " ' BEGIN { print a + b }' )
508512
509513 # read test using dd using the 1G file written during the write test
510514 DISK_READ_TEST=$( dd if=" $DISK_PATH /$DATE .test" of=/dev/null bs=8k | & grep copied | awk ' { print $(NF-1) " " $(NF)}' )
511- VAL=$( echo $DISK_READ_TEST | cut -d " " -f 1)
515+ VAL=$( echo " $DISK_READ_TEST " | cut -d " " -f 1)
512516 [[ " $DISK_READ_TEST " == * " GB" * ]] && VAL=$( awk -v a=" $VAL " ' BEGIN { print a * 1000 }' )
513517 DISK_READ_TEST_RES+=( " $DISK_READ_TEST " )
514518 DISK_READ_TEST_AVG=$( awk -v a=" $DISK_READ_TEST_AVG " -v b=" $VAL " ' BEGIN { print a + b }' )
515519
516- I=$(( $ I + 1 ))
520+ I=$(( I + 1 ))
517521 done
518522 # calculate the write and read speed averages using the results from the three runs
519523 DISK_WRITE_TEST_AVG=$( awk -v a=" $DISK_WRITE_TEST_AVG " ' BEGIN { print a / 3 }' )
@@ -531,13 +535,13 @@ elif [ -z "$SKIP_FIO" ]; then
531535 # Perform ZFS filesystem detection and determine if we have enough free space according to spa_asize_inflation
532536 ZFSCHECK=" /sys/module/zfs/parameters/spa_asize_inflation"
533537 if [[ -f " $ZFSCHECK " ]]; then
534- mul_spa=$(( ( $(cat / sys/ module/ zfs/ parameters/ spa_asize_inflation)* 2 ) ) )
538+ mul_spa=$(( $(cat / sys/ module/ zfs/ parameters/ spa_asize_inflation) * 2 ))
535539 warning=0
536540 poss=()
537541
538542 for pathls in $( df -Th | awk ' {print $7}' | tail -n +2)
539543 do
540- if [[ " ${PWD## $pathls } " != " ${ PWD} " ]]; then
544+ if [[ " ${PWD## $pathls } " != " $PWD " ]]; then
541545 poss+=(" $pathls " )
542546 fi
543547 done
@@ -546,14 +550,14 @@ elif [ -z "$SKIP_FIO" ]; then
546550 m=-1
547551 for x in " ${poss[@]} "
548552 do
549- if [ ${# x} -gt $m ]; then
553+ if [ " ${# x} " -gt " $m " ]; then
550554 m=${# x}
551555 long=$x
552556 fi
553557 done
554558
555- size_b=$( df -Th | grep -w $long | grep -i zfs | awk ' {print $5}' | tail -c -2 | head -c 1)
556- free_space=$( df -Th | grep -w $long | grep -i zfs | awk ' {print $5}' | head -c -2)
559+ size_b=$( df -Th | grep -w " $long " | grep -i zfs | awk ' {print $5}' | tail -c -2 | head -c 1)
560+ free_space=$( df -Th | grep -w " $long " | grep -i zfs | awk ' {print $5}' | head -c -2)
557561
558562 if [[ $size_b == ' T' ]]; then
559563 free_space=$( awk " BEGIN {print int($free_space * 1024)}" )
0 commit comments