-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetiops.sh
executable file
·211 lines (185 loc) · 8.65 KB
/
getiops.sh
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
###########################################################################################
#
# Source: https://github.com/secure-diversITy/get_iops
# Copyright: 2015-2024 Thomas Fischer <mail |AT| sedi #DOT# one>
# License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
#
# Desc: Stress your storage setup to find out IOPS
#
###########################################################################################
#
# Usage & Installation: Checkout README !!
#
#########################################################################################
#
VER=2.5.0
#
#########################################################################################
EPATH=$(dirname $0) # detect path we're running in
VARFILE=libs/vars
DEBUG=0
TOOLARGS="$@"
[ ! -f $VARFILE ] && echo "ERROR: missing variable file <$VARFILE>" && exit
source $VARFILE
[ ! -d "$FUNCS" ]&& echo -e "\n\tERROR: cannot find $FUNCS path..." && exit
for fc in $(ls $FUNCS);do
. $FUNCS/$fc
if [ $? -ne 0 ];then
echo -e "\tERROR: $FUNCS/$fc cannot be included! Aborted.."
exit 3
else
[ $DEBUG -eq 1 ] && echo -e "\t... $fc included"
fi
done
F_USAGE(){
cat << _EOHELP
Version: $VER
A simple helper to guide you through the jungle of IOPS testing.
Although this is provided without warranty of any kind (and you use it at your own risk), it was created in the hope of being useful.
Brought to you by secure diversITy (www.sicherevielfalt.de).
Simply execute ./getiops.sh to start the interactive mode.
The following CLI parameters exist which will skip interactive questions:
general:
-u | --user [username] starting get_iops.sh as root requires a local user to actually run the tests
ensure that this user has read+write access at your test path
if you specify "root" as username it will proceed (on your own risk, of course)
-t | --type [value] sets the type:
1 or "bonnie++", 2 or "iozone", 3 or "fio", 4 or "ioping"
note: bonnie++ requires also iostat to be installed
-b | --batch will run in batch mode (avoid any output - Note: WIP)
--nodiskop skip warning about to stop disk operations
--useram [X|auto] define a specific amount of RAM in MB (for cache calculations)
--size [X|auto] define test file size in MB (when "auto": Total RAM * 2)
--path [path/mountpoint] set the path to the storage you want to test
bonnie++ only:
--nowarn skip warning about usage
--nfiles [X] number of files to write
--ndirs [X] number of directories to write
--tests [X|default] number of test runs
fio only:
--blocksize [X] define a non-default block size
--cores [X|auto] set the amount of cores
not available in interactive mode:
--readperc [X|default] percentage of a mixed workload that should be read (+ writeperc must be 100)
--writeperc [X|default] percentage of a mixed workload that should be written (+ readperc must be 100)
--iodepth [X|default] "default" is highly recommended here
--runtime [X]h|m|s the maximal runtime (might complete before). if unit is omitted seconds will be assumed.
--loop requires --runtime to be set!
will run for the duration of the --runtime specified even if the file(s) are completely
read or written. It will loop over the same workload as many times as the runtime allows.
iozone only:
--rsizes "[X|default]" the record sizes to use (must be quoted if not "default")
--cores [X|auto] set the amount of cores to use for throughput mode
--tests "[X|default]" tests to run (must be quoted, e.g. --tests "0 2 8"):
0=write/rewrite, 1=read/re-read, 2=random-read/write, 3=Read-backwards, 4=Re-write-record
5=stride-read, 6=fwrite/re-fwrite, 7=fread/Re-fread, 8=mixed workload, 9=pwrite/Re-pwrite
10=pread/Re-pread, 11=pwritev/Re-pwritev, 12=preadv/Re-preadv
interactive mode can be mixed with those parameters, i.e. if you do not specify all
possible parameters for a type you will be prompted.
Additionally the following environment variables can be used to overwrite the default binary paths:
IZBIN full path to your iozone binary
FIOBIN full path to your fio binary
BONBIN full path to your bonnie++ binary
IOSTATBIN full path to your iostat binary (required for bonnie++)
RESULTPATH full path where results should be stored
simply export those before executing (e.g. export IZBIN=/usr/local/bin/iozone)
or together with the running set (e.g. IZBIN=/usr/local/bin/iozone ./getiops.sh --type iozone ....)
_EOHELP
}
# check/set args
while [ ! -z "$1" ]; do
case "$1" in
-h|--help|help) F_USAGE; exit;;
-t|--type) CHOICE=$2; shift 2;;
-u|--user) RUNUSER=$2; shift 2;;
-a|--batch) BATCH=1; shift ;;
--nowarn) export SKIPWARN=y; shift ;;
--nodiskop) export IOPROC=y; shift ;;
--useram) export RAM="$2"; shift 2;;
--size) export TSIZE="$2"; shift 2;;
--path) export STORAGE="$2"; shift 2;;
--tests) export TESTS="$2"; shift 2;;
--rsizes) export RSIZES="$2"; shift 2;;
--blocksize) export BLKSIZE="$2"; shift 2;;
--cores|--jobs) export CPUCOUNT="$2"; shift 2;;
--nfiles) export NFILES="$2"; shift 2;;
--ndirs) export NDIRS="$2"; shift 2;;
--readperc) export FIOREADPERC="$2"; shift 2;;
--writeperc) export FIOWRITEPERC="$2"; shift 2;;
--iodepth) export FIOIODEPTH="$2"; shift 2;;
--runtime) export FIOMAXRUNTIME="$2"; shift 2;;
--loop) export FIOLOOP="y"; shift;;
*) echo "unknown arg: $1"; F_USAGE; exit 4;;
esac
done
# check if we are root
if [ "$(id -u)" == 0 -a -z "$RUNUSER" ];then
echo -e "\nERROR: You are running $0 as root but do not have specified a local user (-u|--user)"
echo -e "If you really want to run as root specify -u root (not recommended)."
echo -e "Software can have bugs and even though an unprivileged user can damage data,"
echo -e "running as root can take serious damage to the whole system!\n"
exit 4
fi
# setup run user
[ -z "$RUNUSER" ] && export RUNUSER="$(id -un)"
export BINARGS="sudo -u $RUNUSER"
# starting interactive mode
while [ -z "$CHOICE" ];do
# users choice
echo -e "\n\tWelcome and tighten your seat belts. We are about to stress your storage setup!"
echo -e "\tThere are several tools out there which can measure things. The question is which of those"
echo -e "\tis doing it the right way?\n\tThe short answer? Test them all ;)\n"
echo -e "\tNow let's start. Which tool do you want to use today?\n"
echo -e "\t[1] = bonnie++"
echo -e "\t[2] = iozone"
echo -e "\t[3] = fio"
echo -e "\t[4] = ioping (I/O latency only)"
echo
read -p "type in the digit from above: > " CHOICE
done
# pre-check binaries
case $CHOICE in
1|bonnie++) bin="$BONBIN"
if [ ! -x "$IOSTATBIN" ];then
echo -e "\nrunning bonnie++ requires iostat to determine IOPS, which seems to be not installed\n"
exit 3
fi
;;
2|iozone) bin="$IZBIN" ;;
3|fio) bin="$FIOBIN";;
4|ioping) echo coming soon; exit ;;
*)echo -e "\nERROR: invalid choice >$CHOICE<\n"; F_USAGE; exit 4 ;;
esac
if [ ! -x $bin ];then
echo -e "\n\tERROR: Cannot find $bin or it is not executable! ABORTED.\n"
exit 3
else
echo -e "\t.. $bin detected correctly"
fi
# do what the user want to do
# the first argument when exec a function is always the batch mode.
# 0 means interactive. 1 means batch mode.
case $CHOICE in
1|bonnie++) # bonnie++
F_BONNIE 0
;;
2|iozone) # iozone
F_IOZONE 0
;;
3|fio) # fio
F_FIO 0
;;
4|ioping) # ioping
F_IOPING 0
;;
esac
$BINARGS rm ${STORAGE}/${TYPE}.test*
echo -e "\n$TYPE finished! You can find the result output here: \n"
[ -f "$CSV" ] && echo -e "\tCSV:\t\t$CSV"
[ -f "${CSV}.xls" ] && echo -e "\tXLS:\t\t${CSV}.xls"
[ -f "${CSV}.htm" ] && echo -e "\tHTML:\t\t${CSV}.htm"
echo -e "\tFull output:\t$OUT"
echo -e "\tLog file:\t$LOG\n\n"
F_LOG "$TYPE finished"
F_LOG "#-------------------------------------------------------------------"