forked from markstanton/sysbench-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-sysbench
executable file
·102 lines (85 loc) · 2.46 KB
/
run-sysbench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -u
usage()
{
cat << EOF
usage: $0 options
This script runs sysbench and iostat concurrently in iterations with each iteration using a higher
number of threads than the last. The results are written to a new result directory each time the
script is run. A file '.run_number' keeps track of the result directory numbering ensuring that
each new run gets a new directory.
OPTIONS:
-h MySQL host [localhost]
-P MySQL port [3306]
-s MySQL socket [/tmp/mysql.sock]
-u MySQL username [root]
-p MySQL password
-w ReadWrite mode (on/off) [on]
-o Timeout for each sysbench run [60]
-r Directory to print results to [./results]
-t List of thread counts to iterate [4 8 16 32 64 128 256]
EOF
}
host=localhost
port=3306
socket=/tmp/mysql.sock
user=root
password=
readwrite=on
readonly=off
timeout=60
threads="8,16,32,64,128"
resultsdir=./results
connparams=
while getopts h:P:s:u:p:w:o:r:t: name
do
case $name in
h) host="$OPTARG";;
P) port="$OPTARG";;
s) socket="$OPTARG";;
u) user="$OPTARG";;
p) password="$OPTARG";;
w) readwrite="$OPTARG";;
o) timeout="$OPTARG";;
r) resultsdir="$OPTARG";;
t) threads="$OPTARG";;
?) usage
exit;;
esac
done
threads=${threads//,/ }
if [ "$readwrite" == "off" ]; then
readonly=on
fi
if [ ! "$socket" == "/tmp/mysql.sock" ]; then
connparams="--mysql-socket=$socket --mysql-user=$user --mysql-password=$password"
else
connparams="--mysql-host=$host --mysql-port=$port --mysql-user=$user --mysql-password=$password"
fi
# Determine run number for selecting an output directory
mkdir -p $resultsdir
run_num=-1
if [ -f "$resultsdir/.run_number" ]; then
read run_num < $resultsdir/.run_number
fi
if [ $run_num -eq -1 ]; then
run_num=1
fi
if [ $run_num -lt 10 ]; then
outdir=result-0$run_num
else
outdir=result-$run_num
fi
mkdir -p $resultsdir/$outdir
run_num=`expr $run_num + 1`
echo $run_num > $resultsdir/.run_number
for thread in $threads
do
# Run iostat
iostat -dx 10 $(($timeout/10+1)) >> $resultsdir/$outdir/iostat.$thread.res &
# Run sysbench
sysbench $connparams --test=oltp --init-rng=on --num-threads=$thread \
--oltp-read-only=$readonly --oltp-dist-type=uniform --max-time=$timeout \
--max-requests=0 --percentile=99 run | tee -a $resultsdir/$outdir/sysbench.$thread.res
sleep 10
done