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) | |
72fe3ef1 | 47 | 0 means till the end of the device |
afbbd646 EV |
48 | -b blocksize[,blocksize1, ...] : The blocksizes to test under fio format (4k, 1m, ...) |
49 | Separated each blocksize with a comma | |
50 | -m mode1,[mode2,mode3, ...] : Define the fio IO profile to use like read, write, randread, randwrite | |
51 | ||
52 | Example: | |
53 | ||
54 | $PROG -d sdb,sdc,sdd,sde -a -b 4k,128k,1m -r 100 -a | |
55 | ||
56 | Will generate an fio file that will run | |
57 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with read,write,randread,randwrite tests | |
58 | ETA ~ 4 tests * 4 disks * 100 seconds | |
59 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with read,write,randread,randwrite tests | |
60 | ETA ~ 4 tests * 4 disks * 100 seconds | |
61 | - a sequential bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with read,write,randread,randwrite tests | |
62 | ETA ~ 4 tests * 4 disks * 100 seconds | |
63 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 4k with read,write,randread,randwrite tests | |
64 | ETA ~ 4 tests * 100 seconds | |
65 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 128k with read,write,randread,randwrite tests | |
66 | ETA ~ 4 tests * 100 seconds | |
67 | - a parallel bench on /dev/sdb /dev/sdc /dev/sdd /dev/sde for block size = 1m with read,write,randread,randwrite tests | |
68 | ETA ~ 4 tests * 100 seconds | |
69 | ||
70 | Generating localhost-4k,128k,1m-all-read,write,randread,randwrite-sdb,sdc,sdd,sde.fio | |
71 | Estimated Time = 6000 seconds : 1 hour 40 minutes | |
72 | EOF | |
73 | } | |
74 | ||
75 | gen_template() { | |
76 | cat >$TEMPLATE << EOF | |
77 | [global] | |
78 | ioengine=libaio | |
79 | invalidate=1 | |
afbbd646 EV |
80 | ramp_time=5 |
81 | direct=1 | |
72fe3ef1 | 82 | EOF |
afbbd646 | 83 | |
72fe3ef1 EV |
84 | if [ "$RUNTIME" != "0" ]; then |
85 | cat >>$TEMPLATE << EOF | |
86 | runtime=$RUNTIME | |
afbbd646 | 87 | EOF |
72fe3ef1 EV |
88 | fi |
89 | ||
afbbd646 EV |
90 | } |
91 | ||
92 | gen_seq_suite() { | |
93 | TYPE=$1 | |
94 | cat >> $OUTFILE << EOF | |
95 | [$TYPE-$disk-$BLK_SIZE-seq] | |
96 | stonewall | |
97 | bs=$BLK_SIZE | |
98 | filename=/dev/$disk | |
99 | rw=$TYPE | |
100 | write_bw_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results | |
101 | write_iops_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-seq.results | |
102 | EOF | |
103 | ETA=$(($ETA + $RUNTIME)) | |
104 | } | |
105 | ||
106 | gen_seq_fio() { | |
107 | for disk in $(echo $DISKS | tr "," " "); do | |
108 | for mode in $(echo $MODES | tr "," " "); do | |
109 | gen_seq_suite "$mode" | |
110 | done | |
111 | done | |
112 | } | |
113 | ||
114 | ||
115 | gen_para_suite() { | |
116 | TYPE=$1 | |
117 | NEED_WALL=$2 | |
118 | D=0 | |
119 | for disk in $(echo $DISKS | tr "," " "); do | |
120 | cat >> $OUTFILE << EOF | |
121 | [$TYPE-$disk-$BLK_SIZE-para] | |
122 | bs=$BLK_SIZE | |
123 | EOF | |
124 | ||
125 | if [ "$D" = 0 ]; then | |
126 | echo "stonewall" >> $OUTFILE | |
127 | D=1 | |
128 | fi | |
129 | ||
130 | cat >> $OUTFILE << EOF | |
131 | filename=/dev/$disk | |
132 | rw=$TYPE | |
133 | write_bw_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results | |
134 | write_iops_log=$SHORT_HOSTNAME-$BLK_SIZE-$disk-$TYPE-para.results | |
135 | EOF | |
136 | done | |
137 | ||
138 | ETA=$(($ETA + $RUNTIME)) | |
139 | echo >> $OUTFILE | |
140 | } | |
141 | ||
142 | gen_para_fio() { | |
143 | for mode in $(echo $MODES | tr "," " "); do | |
144 | gen_para_suite "$mode" | |
145 | done | |
146 | } | |
147 | ||
148 | gen_fio() { | |
149 | case $SEQ in | |
150 | 2) | |
151 | gen_seq_fio | |
152 | gen_para_fio | |
153 | ;; | |
154 | 1) | |
155 | gen_seq_fio | |
156 | ;; | |
157 | 0) | |
158 | gen_para_fio | |
159 | ;; | |
160 | esac | |
161 | } | |
162 | ||
163 | parse_cmdline() { | |
164 | while getopts "hapsd:b:r:m:" opt; do | |
165 | case $opt in | |
166 | h) | |
167 | show_help | |
168 | exit 0 | |
169 | ;; | |
170 | b) | |
171 | BLOCK_SIZE=$OPTARG | |
172 | ;; | |
173 | s) | |
174 | if [ "$SEQ" = "-1" ]; then | |
175 | SEQ=1 | |
176 | fi | |
177 | ;; | |
178 | r) | |
179 | RUNTIME=$OPTARG | |
180 | ;; | |
181 | p) | |
182 | if [ "$SEQ" = "-1" ]; then | |
183 | SEQ=0 | |
184 | fi | |
185 | ;; | |
186 | m) | |
187 | MODES=$OPTARG; | |
188 | ;; | |
189 | d) | |
190 | DISKS=$OPTARG | |
191 | ;; | |
192 | a) | |
193 | SEQ=2 | |
194 | ;; | |
195 | \?) | |
196 | echo "Invalid option: -$OPTARG" >&2 | |
197 | ;; | |
198 | esac | |
199 | done | |
200 | ||
201 | if [ "$SEQ" = "-1" ]; then | |
202 | SEQ=0 | |
203 | fi | |
204 | ||
205 | SHORT_HOSTNAME=$(hostname -s) | |
206 | case $SEQ in | |
207 | 2) | |
208 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-all-$MODES-$DISKS.fio | |
209 | ;; | |
210 | ||
211 | 1) | |
212 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-sequential-$MODES-$DISKS.fio | |
213 | ;; | |
214 | 0) | |
215 | OUTFILE=$SHORT_HOSTNAME-$BLOCK_SIZE-parallel-$MODES-$DISKS.fio | |
216 | ;; | |
217 | esac | |
218 | ||
219 | if [ -z "$DISKS" ]; then | |
220 | echo "Missing DISKS !" | |
221 | echo "Exiting !" | |
222 | exit 1 | |
223 | fi | |
224 | ||
225 | } | |
226 | ||
227 | ||
228 | ########## MAIN | |
229 | parse_cmdline $@ | |
230 | gen_template | |
231 | ||
232 | echo "Generating $OUTFILE" | |
233 | cp -f $TEMPLATE $OUTFILE | |
234 | echo >> $OUTFILE | |
235 | ||
236 | for BLK_SIZE in $(echo $BLOCK_SIZE | tr "," " "); do | |
237 | gen_fio | |
238 | done | |
239 | ETA_H=$(($ETA / 3600)) | |
240 | ETA_M=$((($ETA - ($ETA_H*3600)) / 60)) | |
72fe3ef1 EV |
241 | if [ "$ETA_M" = "0" ]; then |
242 | echo "Cannot estimate ETA as RUNTIME=0" | |
243 | else | |
244 | echo "Estimated Time = $ETA seconds : $ETA_H hour $ETA_M minutes" | |
245 | fi |