2019-05-10

iops-harddisk.sh

###################################
#FILE_NAME: /opt/script/iops-harddisk.sh
#Author: qwerty | tinhcx@gmail.com
#LastUpdate: #13:58 2019.05.10
###################################
#Test IOPS READ/WRITE 100MB 5 lan: iops-harddisk.sh 100M 5 <LOCATION>
#iops-harddisk.sh 100M 5 /data/temp/
#iops-harddisk.sh 50K 500 /data/temp/
###################################
# #IOPS CALCULATE:
# #{
# #INSTALL:
# #{
# mkdir -p /opt/setup
# cd /opt/setup
# yum install -y make gcc libaio-devel || ( apt-get -y update && apt-get install -y make gcc libaio-dev  </dev/null )
# wget https://github.com/Crowd9/Benchmark/raw/master/fio-2.0.9.tar.gz ; tar xf fio*
# cd fio-2.0.9;make;make install

# cp fio /opt/script/fio.sh
# ls -lh /opt/script/fio.sh
# /bin/rm -rf fio*
# #
# #}

###################################CONTENT:BEGIN
VAL1=$1
VAL2=$2
VAL3=$3

mkdir -p /db/
mkdir -p /data/
mkdir -p /opt/temp/
mkdir -p /opt/log/iops-result/

FILE_SIZE=$VAL1

#RESULT_LOG=/opt/log/iops-result/iops-harddisk-$FILE_SIZE-$now1.log
RESULT_LOG=/opt/log/iops-result/iops-harddisk-$FILE_SIZE-nTime.log

for ((iCounter=1; iCounter<=$VAL2; iCounter++))
do
#______________________________IOP_TEST:BEGIN
HARD_DISK=$VAL3/$(date +'%Y.%m.%d-%H.%M.%S.%3N')_test_$iCounter.data
echo "" >> $RESULT_LOG
echo "" >> $RESULT_LOG
echo "########################################BEGIN" $iCounter/$VAL2 > $RESULT_LOG


now1="$(date +'%Y.%m.%d-%H.%M.%S.%3N')"
date1=$now1

fio.sh --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=$HARD_DISK --bs=4k --iodepth=64 --size=$FILE_SIZE --readwrite=randrw --rwmixread=75 >> $RESULT_LOG

now1="$(date +'%Y.%m.%d-%H.%M.%S.%3N')"
date2=$now1


echo "START:" $date1  >> $RESULT_LOG
echo "END  :" $date2  >> $RESULT_LOG
echo "########################################END" $iCounter/$VAL2 >> $RESULT_LOG
#______________________________IOP_TEST:END

echo "__________________________"    >> $RESULT_LOG.cont.log
echo "#iops-harddisk.sh" $VAL1 $VAL2 >> $RESULT_LOG.cont.log
echo "IOP_TEST COUNTER: " $iCounter/$VAL2    >> $RESULT_LOG.cont.log
cat $RESULT_LOG | egrep "test: \(groupid|read : io=|write: io=" >> $RESULT_LOG.cont.log
cat $RESULT_LOG | egrep "START:|END  :" >> $RESULT_LOG.cont.log


####
done
###################################CONTENT:END
/bin/rm -rf $VAL3/*test*.data

#THE-END

No comments:

Post a Comment