Last active
August 29, 2015 14:23
-
-
Save jschaub30/5021231a5396e70e4572 to your computer and use it in GitHub Desktop.
Bash script to test sequential IO (read and write) and read IOPS using ioping utility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Test sequential IO (read and write) and read IOPS | |
# Creates CSV and HTML output | |
# Usegu: ./measure_io.sh [DIRECTORY] | |
CWD=$1 | |
[ $# -lt 1 ] && CWD=$(pwd) | |
ioping -h 2> tmpfile | |
[ $? -ne 0 ] && echo ioping not found--"sudo apt-get install ioping" or download here: https://code.google.com/p/ioping/ && exit 1 | |
rm tmpfile | |
TEST_TIME=10 | |
TS=$(date +"%Y%m%d-%H%M%S") | |
create_html() { | |
# Called at end to convert csv files to html tables | |
OUT_FILE=sequential.$TS.csv | |
echo Creating sequential.$TS.html | |
./csv2html.sh $OUT_FILE > sequential.$TS.html | |
if [ $? -ne 0 ] | |
then | |
echo ERROR--csv2html not found. Downloading... | |
wget https://gist.githubusercontent.com/jschaub30/c67cf9e214d83accd4db/raw/fe9ce4bb916b6b0fc431e36172bace18bc88b925/csv2html.sh | |
chmod u+x csv2html.sh | |
./csv2html.sh $OUT_FILE > sequential.$TS.html | |
fi | |
OUT_FILE=iops.$TS.csv | |
echo Writing to iops.$TS.html | |
./csv2html.sh $OUT_FILE > iops.$TS.html | |
} | |
trap 'create_html' SIGTERM SIGINT # Create html files if killed early | |
echo ;echo "######################## SEQUENTIAL TESTS ########################" | |
OUT_FILE=sequential.$TS.csv | |
echo Writing to $OUT_FILE | |
echo "Block size [MB],Read throughput [MBps],Write throughput [MBps]" > $OUT_FILE | |
for BS in 1 4 16 64 256 | |
do | |
echo --------------------- | |
echo Sequential read, directory=\"$CWD\", block size=$BS MB | |
READ=$(ioping -B -q -i 0 -w $TEST_TIME -s ${BS}M -D $CWD | cut -d' ' -f 4) | |
echo Sequential write, directory=\"$CWD\", block size=$BS MB | |
WRITE=$(ioping -B -q -i 0 -w $TEST_TIME -s ${BS}M -D -W $CWD | cut -d' ' -f 4) | |
echo $BS,$((READ/1000000)),$((WRITE/1000000)) >> $OUT_FILE | |
done | |
echo ;echo "######################## READ IOPS TEST ########################" | |
OUT_FILE=iops.$TS.csv | |
echo Writing to $OUT_FILE | |
echo "Block size [KB],IOPS" > $OUT_FILE | |
for BS in 1 4 16 | |
do | |
echo --------------------- | |
echo IOPS, directory=\"$CWD\", block size=$BS KB | |
IOPS=$(ioping -B -q -i 0 -w $TEST_TIME -s ${BS}k -S $((BS*16))m $CWD | cut -d' ' -f 3) | |
echo $BS,$IOPS >> $OUT_FILE | |
done | |
create_html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment