Commit | Line | Data |
---|---|---|
afbbd646 EV |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2013 eNovance SAS <licensing@enovance.com> | |
4 | # Author: Erwan Velu <erwan@enovance.com> | |
5 | # | |
6 | # The license below covers all files distributed with fio unless otherwise | |
7 | # noted in the file itself. | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License version 2 as | |
11 | # published by the Free Software Foundation. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | ||
22 | BLK_SIZE= | |
23 | BLOCK_SIZE=4k | |
24 | SEQ=-1 | |
25 | TEMPLATE=/tmp/template.fio | |
26 | OUTFILE= | |
27 | DISKS= | |
28 | RUNTIME=300 | |
29 | ETA=0 | |
30 | MODES="read,write,randread,randwrite" | |
31 | SHORT_HOSTNAME= | |
32 | ||
33 | show_help() { | |
34 | PROG=$(basename $0) | |
35 | echo "usage of $PROG:" | |
36 | cat << EOF | |
37 | -h : Show this help & exit | |
38 | -a : Run sequential test then parallel one | |
39 | -s : Run sequential test (default value) | |
40 | one test after another then one disk after another | |
41 | -p : Run parallel test | |
42 | one test after anoter but all disks at the same time | |
43 | -d disk1[,disk2,disk3,..] : Run the tests on the selected disks | |
44 | Separated each disk with a comma | |
45 | Disk name shall be "sdxx", /dev/ shall NOT be used here | |
46 | -r seconds : Time in seconds per benchmark (300 as default) | |
47 | A simple task is set of 4 benchmarks : | |
48 | read,write,randread,randwrite | |
49 | -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...) | |
50 | Separated each blocksize with a comma | |
51 | -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite | |
52 | ||
53 | Example: | |
54 | ||
55 | $PROG -d sdb,sdc,sdd,sde -a -b 4k,128k,1m -r 100 -a | |
56 | ||
57 | Will generate an fio file that will run | |
58 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with read,write,randread,randwrite tests | |
59 | ETA ~ 4 tests * 4 disks * 100 seconds | |
60 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with read,write,randread,randwrite tests | |
61 | ETA ~ 4 tests * 4 disks * 100 seconds | |
62 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with read,write,randread,randwrite tests | |
63 | ETA ~ 4 tests * 4 disks * 100 seconds | |
64 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with read,write,randread,randwrite tests | |
65 | ETA ~ 4 tests * 100 seconds | |
66 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with read,write,randread,randwrite tests | |
67 | ETA ~ 4 tests * 100 seconds | |
68 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with read,write,randread,randwrite tests | |
69 | ETA ~ 4 tests * 100 seconds | |
70 | ||
71 | Generating localhost-4k,128k,1m-all-read,write,randread,randwrite-sdb,sdc,sdd,sde.fio | |
72 | Estimated Time = 6000 seconds : 1 hour 40 minutes | |
73 | EOF | |
74 | } | |
75 | ||
76 | gen_template() { | |
77 | cat >$TEMPLATE << EOF | |
78 | [global] | |
79 | ioengine=libaio | |
80 | invalidate=1 | |
81 | runtime=$RUNTIME | |
82 | ramp_time=5 | |
83 | direct=1 | |
84 | ||
85 | EOF | |
86 | } | |
87 | ||
88 | gen_seq_suite() { | |
89 | TYPE=$1 | |
90 | cat >> $OUTFILE << EOF | |
91 | [$TYPE-$disk-$BLK_SIZE-seq] | |
92 | stonewall | |
93 | bs=$BLK_SIZE | |
94 | filename=/dev/$disk | |
95 | rw=$TYPE | |
96 | write_bw_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results | |
97 | write_iops_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results | |
98 | EOF | |
99 | ETA=$(($ETA + $RUNTIME)) | |
100 | } | |
101 | ||
102 | gen_seq_fio() { | |
103 | for disk in $(echo $DISKS | tr "," " "); do | |
104 | for mode in $(echo $MODES | tr "," " "); do | |
105 | gen_seq_suite "$mode" | |
106 | done | |
107 | done | |
108 | } | |
109 | ||
110 | ||
111 | gen_para_suite() { | |
112 | TYPE=$1 | |
113 | NEED_WALL=$2 | |
114 | D=0 | |
115 | for disk in $(echo $DISKS | tr "," " "); do | |
116 | cat >> $OUTFILE << EOF | |
117 | [$TYPE-$disk-$BLK_SIZE-para] | |
118 | bs=$BLK_SIZE | |
119 | EOF | |
120 | ||
121 | if [ "$D" = 0 ]; then | |
122 | echo "stonewall" >> $OUTFILE | |
123 | D=1 | |
124 | fi | |
125 | ||
126 | cat >> $OUTFILE << EOF | |
127 | filename=/dev/$disk | |
128 | rw=$TYPE | |
129 | write_bw_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results | |
130 | write_iops_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results | |
131 | EOF | |
132 | done | |
133 | ||
134 | ETA=$(($ETA + $RUNTIME)) | |
135 | echo >> $OUTFILE | |
136 | } | |
137 | ||
138 | gen_para_fio() { | |
139 | for mode in $(echo $MODES | tr "," " "); do | |
140 | gen_para_suite "$mode" | |
141 | done | |
142 | } | |
143 | ||
144 | gen_fio() { | |
145 | case $SEQ in | |
146 | 2) | |
147 | gen_seq_fio | |
148 | gen_para_fio | |
149 | ;; | |
150 | 1) | |
151 | gen_seq_fio | |
152 | ;; | |
153 | 0) | |
154 | gen_para_fio | |
155 | ;; | |
156 | esac | |
157 | } | |
158 | ||
159 | parse_cmdline() { | |
160 | while getopts "hapsd:b:r:m:" opt; do | |
161 | case $opt in | |
162 | h) | |
163 | show_help | |
164 | exit 0 | |
165 | ;; | |
166 | b) | |
167 | BLOCK_SIZE=$OPTARG | |
168 | ;; | |
169 | s) | |
170 | if [ "$SEQ" = "-1" ]; then | |
171 | SEQ=1 | |
172 | fi | |
173 | ;; | |
174 | r) | |
175 | RUNTIME=$OPTARG | |
176 | ;; | |
177 | p) | |
178 | if [ "$SEQ" = "-1" ]; then | |
179 | SEQ=0 | |
180 | fi | |
181 | ;; | |
182 | m) | |
183 | MODES=$OPTARG; | |
184 | ;; | |
185 | d) | |
186 | DISKS=$OPTARG | |
187 | ;; | |
188 | a) | |
189 | SEQ=2 | |
190 | ;; | |
191 | \?) | |
192 | echo "Invalid option: -$OPTARG" >&2 | |
193 | ;; | |
194 | esac | |
195 | done | |
196 | ||
197 | if [ "$SEQ" = "-1" ]; then | |
198 | SEQ=0 | |
199 | fi | |
200 | ||
201 | SHORT_HOSTNAME=$(hostname -s) | |
202 | case $SEQ in | |
203 | 2) | |
204 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$DISKS.fio | |
205 | ;; | |
206 | ||
207 | 1) | |
208 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$DISKS.fio | |
209 | ;; | |
210 | 0) | |
211 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$DISKS.fio | |
212 | ;; | |
213 | esac | |
214 | ||
215 | if [ -z "$DISKS" ]; then | |
216 | echo "Missing DISKS !" | |
217 | echo "Exiting !" | |
218 | exit 1 | |
219 | fi | |
220 | ||
221 | } | |
222 | ||
223 | ||
224 | ########## MAIN | |
225 | parse_cmdline $@ | |
226 | gen_template | |
227 | ||
228 | echo "Generating $OUTFILE" | |
229 | cp -f $TEMPLATE $OUTFILE | |
230 | echo >> $OUTFILE | |
231 | ||
232 | for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do | |
233 | gen_fio | |
234 | done | |
235 | ETA_H=$(($ETA / 3600)) | |
236 | ETA_M=$((($ETA - ($ETA_H*3600)) / 60)) | |
237 | echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes" |