sbc-performance-test-kit/bin/disk-test.sh

49 lines
2.3 KiB
Bash
Raw Normal View History

2021-01-10 23:40:11 +00:00
#!/bin/bash
if [[ $# -lt 3 ]] ; then
echo "\\o/"
echo "Not enough arguments supplied" >&2
echo "You need to pass a log file name to store the test results, the disk space to use and the number of files to use " >&2
echo " |" >&2
echo "syntax: " >&2
echo " $(basename $0) <log file name> <test disk space> <test file num>" >&2
echo "example: " >&2
echo " $(basename $0) test.log 64G 512 " >&2
echo "/!\\" >&2
exit 1
fi
LOGFILE=$1
TEST_DISK_SPACE=$2
TEST_FILE_NUM=$3
#FILE_IO_MODE=async
FILE_IO_MODE=sync
THREADS=8
#BLOCK_SIZE=16384
BLOCK_SIZE=1048576
#BLOCK_SIZE=4194304
echo ' '
echo "#### Disk test ####" | tee -a $LOGFILE
BLOCK_DEVICES=$(lsblk | grep -v loop | grep disk | cut -f1 -d ' ')
for d in $BLOCK_DEVICES
do
echo "# block device /dev/$d => hdparm -tT #" | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
done
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
echo "# sysbench random read/write test in current directory #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=rndrw --file-block-size=$BLOCK_SIZE --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE --file-rw-ratio=2 2>&1 | tee -a $LOGFILE
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
echo "# sysbench sequential read test in current directory #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqrd --file-block-size=$BLOCK_SIZE --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
echo "# sysbench sequential write test in current directory #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqwr --file-block-size=$BLOCK_SIZE --file-io-mode=async --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
/usr/local/bin/sysbench fileio cleanup --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE