磁盘性能压测脚本

#!/bin/bash

#env

BS_SIZE=$1

DD_COUNT=$2

DD_PATH=$3

if test -z "${BS_SIZE}" || test -z"${DD_COUNT}"

then

        BS_SIZE=4k

        DD_COUNT=2621440

fi

if test -z "${DD_PATH}"

then

        DD_PATH=/tmp

fi

# Echo env

echo "Current BS value: ${BS_SIZE}"

echo "Test values total: ${DD_COUNT}"

echo "Pressure measurement path: ${DD_PATH}"

# write Test

echo "Write Testing ... ..."

sync; /usr/bin/time -p bash -c "(dd if=/dev/zero of=${DD_PATH}/test.dd  bs=${BS_SIZE} count=${DD_COUNT})" > /tmp/${BS_SIZE}write.dd 2>&1 &

iostat -x 1 60 > /tmp/${BS_SIZE}iowrite.log &

wait

sync

echo `date +"%Y-%m-%d %H:%M.%S"` > /tmp/${BS_SIZE}IO.log

echo "Test Write" >> /tmp/${BS_SIZE}IO.log

echo "-----------------------------------------------------" >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}write.dd >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}iowrite.log >> /tmp/${BS_SIZE}IO.log

rm /tmp/${BS_SIZE}write.dd

rm /tmp/${BS_SIZE}iowrite.log

# read Test

echo "read Testing ... ..."

echo 3 > /proc/sys/vm/drop_caches; /usr/bin/time -p bash -c "(dd if=${DD_PATH}/test.dd of=/dev/null bs=${BS_SIZE})" > /tmp/${BS_SIZE}Read.dd 2>&1 &

iostat -x 1 60 > /tmp/${BS_SIZE}ioRead.log &

wait

sync

echo `date +"%Y-%m-%d %H:%M.%S"` >> /tmp/${BS_SIZE}IO.log

echo "Test Read" >> /tmp/${BS_SIZE}IO.log

echo "-----------------------------------------------------" >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}Read.dd >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}ioRead.log >> /tmp/${BS_SIZE}IO.log

rm /tmp/${BS_SIZE}Read.dd

rm /tmp/${BS_SIZE}ioRead.log

# read and write

echo "Read and write concurrency testing ... ..."

sync; echo 3 > /proc/sys/vm/drop_caches; /usr/bin/time -p bash -c "(dd if=${DD_PATH}/test.dd of=${DD_PATH}/test2.dd bs=${BS_SIZE})" > /tmp/${BS_SIZE}IO.dd 2>&1 &

iostat -x 1 60 > /tmp/${BS_SIZE}io.log &

wait

sync

echo `date +"%Y-%m-%d %H:%M.%S"` >> /tmp/${BS_SIZE}IO.log

echo "Read And Write" >> /tmp/${BS_SIZE}IO.log

echo "-----------------------------------------------------" >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}IO.dd >> /tmp/${BS_SIZE}IO.log

cat /tmp/${BS_SIZE}io.log >> /tmp/${BS_SIZE}IO.log

rm /tmp/${BS_SIZE}IO.dd

rm /tmp/${BS_SIZE}io.log

# clean All data

echo "Clear test data ... ..."

rm ${DD_PATH}/test.dd

rm ${DD_PATH}/test2.dd

echo "Log file: /tmp/${BS_SIZE}IO.log"

你可能感兴趣的:(磁盘性能压测脚本)