ioping.sh – shell wrapper for ioping disk I/O latency benchmark & monitoring tool

ioping.sh is a shell wrapper script for ioping – a disk I/O latency monitoring and benchmarking tool which allows you to measure real time disk I/O, disk seek rate, disk sequential speeds.

1
wget  http://soft.www.com.ht/ioping.sh
1
2
chmod +x ioping.sh
./ioping.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
#!/bin/bash
#######################################################
# Copyright (C) 2011 
# Program: ioping.sh
# Shell script wrapper for ioping code.google.com/p/ioping/
# disk I/O latency measuring tool 
# Updated: September 1st, 2011 AEST 
DESC='shell wrapper script'
AUTHOR='by George Liu (eva2000)'
NAME='ioping'
SCRIPT="$NAME.sh"
SCRIPTURL='code.google.com/p/ioping/'
VER='0.9.8'
URL='http://vbtechsupport.com'
#######################################################
 
IOPINGVER='0.6'
REQUESTSIZE='4 32 64 256'
 
# Set paths
MAKE="$(which make)"
 
#######################################################
 
if [ -f /proc/mdstat ]; then
SOFTRAIDCHECK=`cat /proc/mdstat | grep active`
 
	if [[ ! -z $SOFTRAIDCHECK ]]; then
	DEVICES=`ls /sys/block/ | grep -E '(^sd|^md)'`
	else
	DEVICES='sd*'
	fi
 
else
 
DEVICES='sd*'
 
fi
 
#######################################################
# text functions
 
function funct_ddtest_title {
 
echo "**********************************"
echo "dd (sequential disk speed test)..."
echo "**********************************"
 
}
 
function funct_teststartinfo {
 
echo ""
echo "***************************************************"
echo "$NAME $SCRIPTURL"
echo "$SCRIPT $VER"
echo "$DESC $AUTHOR"
echo "$URL"
echo "***************************************************"
 
}
 
function funct_startingioping {
 
echo ""
echo "************************"
echo "starting ioping tests..."
#echo "************************"
 
}
 
function funct_iopingdiskiodefault {
 
echo "***************************************************"
echo "ioping disk I/O test (default 1MB working set)"
echo "***************************************************"
 
}
 
function funct_iopingdiskseekdefault {
 
echo "**********************************************"
echo "seek rate test (default 1MB working set)"
echo "**********************************************"
 
}
 
function funct_iopingdisksequentialdefault {
 
echo "**********************************************"
echo "sequential test (default 1MB working set)"
echo "**********************************************"
 
}
 
function funct_iopingcustomdiskio {
 
echo ""
echo "################################"
echo "ioping disk I/O test"
echo "(custom $REQUESTSIZE (KB) request size)"
echo "################################"
 
}
 
function funct_iopingcustomdiskseek {
 
echo "################################"
echo "ioping seek rate test"
echo "(custom $REQUESTSIZE (KB) request size)"
echo "################################"
 
}
 
#######################################################
 
 
function funct_ddtest {
 
	if [ -f /etc/rc.d/init.d/vzquota -o -f /proc/user_beancounters ]; then
 
	cd /home
 
	echo ""
	echo "Virtuzzo or OpenVZ Virtualisation detected"	
 
funct_ddtest_title
 
	echo "dd if=/dev/zero of=testfilex bs=64k count=16k conv=fdatasync"
 
	sleep 4
 
	dd if=/dev/zero of=testfilex bs=64k count=16k conv=fdatasync; rm -rf testfilex
 
	else
 
	echo ""
	cd /home
 
funct_ddtest_title
 
	echo "dd if=/dev/zero of=testfilex bs=64k count=16k conv=fdatasync"
 
	echo 3 > /proc/sys/vm/drop_caches
	sleep 4
 
	dd if=/dev/zero of=testfilex bs=64k count=16k conv=fdatasync; rm -rf testfilex
 
	fi
 
}
 
function funct_install {
 
cd /usr/local/src
 
echo ""
echo "***************************************************"
echo "Download ioping-${IOPINGVER}.tar.gz"
echo "***************************************************"
 
if [ -s ioping-${IOPINGVER}.tar.gz ]; then
  echo "ioping-${IOPINGVER}.tar.gz [found]"
  else
  echo "Error: ioping-${IOPINGVER}.tar.gz not found!!!download now......"
  wget -c http://ioping.googlecode.com/files/ioping-${IOPINGVER}.tar.gz
fi
 
echo ""
echo "***************************************************"
echo "Installing ioping ${IOPINGVER}"
echo "***************************************************"
 
tar xvzf ioping-${IOPINGVER}.tar.gz
cd ioping-${IOPINGVER}
make clean
make
make install
 
echo ""
echo "***************************************************"
echo "ioping ${IOPINGVER} installation complete"
echo "***************************************************"
 
}
 
function funct_scheduler {
 
echo "***************************************************"
echo "Disk Schedulers & Read Ahead (Queue Size x 2):"
echo "***************************************************"
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
RA=`blockdev --getra /dev/${DEV} 2>/dev/null`
 
echo "[/dev/${DEV}] - Read Ahead: $RA"
cat /sys/block/${DEV}/queue/scheduler 2>/dev/null
 
echo "----------------------------------"
 
done
 
echo "***************************************************"
 
}
 
function funct_test {
 
funct_teststartinfo
 
funct_scheduler
 
funct_ddtest
 
echo 3 > /proc/sys/vm/drop_caches
funct_startingioping
sleep 5
 
funct_iopingdiskiodefault
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
echo 3 > /proc/sys/vm/drop_caches
sleep 4
 
echo "disk I/O: /dev/${DEV}"
ioping -c 5 /dev/${DEV} | grep -E '(statistics|iops|mdev)'
 
echo ""
done
 
funct_iopingdiskseekdefault
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
echo 3 > /proc/sys/vm/drop_caches
sleep 4
 
echo "seek rate: /dev/${DEV}"
ioping -R /dev/${DEV} | grep -E '(statistics|iops|mdev)'
 
echo ""
done
 
funct_iopingdisksequentialdefault
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
echo 3 > /proc/sys/vm/drop_caches
sleep 4
 
echo "-----------------------"
echo "sequential: /dev/${DEV}"
ioping -RL /dev/${DEV} | grep -E '(statistics|iops|mdev)'
echo "-----------------------"
echo "sequential cached I/O: /dev/${DEV}"
ioping -RLC /dev/${DEV} | grep -E '(statistics|iops|mdev)'
 
echo ""
done
 
}
 
function funct_customtests {
 
echo ""
read -p "Run custom request size ${REQUESTSIZE} (KB) test ? [y/n]: " -t30 customtest;
 
if [ "$?" != "0" ]; then
	echo ""
	echo "You did not answer within 30 seconds. Exiting script..."
	exit 0
fi
 
########################################################
# custom tests begin
 
if [[ "$customtest" = [yY] ]]; then
 
funct_iopingcustomdiskio
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
for WSIZE in $REQUESTSIZE
 
do
 
echo 3 > /proc/sys/vm/drop_caches
sleep 4
 
echo ""
echo "***************************************"
echo "[/dev/${DEV}] ioping disk I/O test: ${WSIZE}K test"
echo "***************************************"
 
ioping -c 5 -s ${WSIZE}K /dev/${DEV} | grep -E '(statistics|iops|mdev)'
 
done
 
echo ""
done
 
funct_iopingcustomdiskseek
 
for DEV in /sys/block/${DEVICES}
do
 
DEV=`echo ${DEV} | sed -e 's/\/sys\/block\///g'`
 
for WSIZE in $REQUESTSIZE
 
do
 
echo 3 > /proc/sys/vm/drop_caches
sleep 4
 
echo ""
echo "***************************************"
echo "[/dev/${DEV}] ioping seek rate test: ${WSIZE}K test"
echo "***************************************"
 
ioping -R -s ${WSIZE}K /dev/${DEV} | grep -E '(statistics|iops|mdev)'
 
done
 
echo ""
done
 
else
 
exit
 
fi
 
# custom tests end
########################################################
 
}
 
function funct_vztest {
 
funct_teststartinfo
 
funct_ddtest
 
#echo 3 > /proc/sys/vm/drop_caches
funct_startingioping
sleep 5
 
funct_iopingdiskiodefault
 
#echo 3 > /proc/sys/vm/drop_caches
#sleep 4
 
echo "disk I/O: /"
ioping -c 5 / | grep -E '(statistics|iops|mdev)'
 
echo ""
 
funct_iopingdiskseekdefault
 
#echo 3 > /proc/sys/vm/drop_caches
#sleep 4
 
echo "seek rate: /"
ioping -R / | grep -E '(statistics|iops|mdev)'
 
echo ""
 
funct_iopingdisksequentialdefault
 
#echo 3 > /proc/sys/vm/drop_caches
#sleep 4
 
echo "-----------------------"
echo "sequential: /"
ioping -RL / | grep -E '(statistics|iops|mdev)'
echo "-----------------------"
echo "sequential cached I/O: /"
ioping -RLC / | grep -E '(statistics|iops|mdev)'
 
echo ""
 
}
 
function funct_vzcustomtests {
 
read -p "Run custom request size ${REQUESTSIZE} (KB) test ? [y/n]: " -t30 customtest;
 
if [ "$?" != "0" ]; then
	echo ""
	echo "You did not answer within 30 seconds. Exiting script..."
	exit 0
fi
 
########################################################
# custom tests begin
 
if [[ "$customtest" = [yY] ]]; then
 
funct_iopingcustomdiskio
 
for WSIZE in $REQUESTSIZE
 
do
 
#echo 3 > /proc/sys/vm/drop_caches
#sleep 4
 
echo ""
echo "***************************************"
echo "[/] ioping disk I/O test: ${WSIZE}K test"
echo "***************************************"
 
ioping -c 5 -s ${WSIZE}K / | grep -E '(statistics|iops|mdev)'
 
done
 
echo ""
 
funct_iopingcustomdiskseek
 
for WSIZE in $REQUESTSIZE
 
do
 
#echo 3 > /proc/sys/vm/drop_caches
#sleep 4
 
echo ""
echo "***************************************"
echo "[/] ioping seek rate test: ${WSIZE}K test"
echo "***************************************"
 
ioping -R -s ${WSIZE}K / | grep -E '(statistics|iops|mdev)'
 
done
 
echo ""
 
else
 
exit
 
fi
 
# custom tests end
########################################################
 
}
 
########################################################
 
while :
do
	# clear
        # display menu
	echo "-----------------------------------------"
		echo "$SCRIPT $VER - $URL"
		echo "$AUTHOR"
	echo "-----------------------------------------"
	echo "          $SCRIPT $VER MENU"
	echo "-----------------------------------------"
	echo "1. Install ioping"
	echo "2. Re-install ioping"
	echo "3. Run ioping default tests"
	echo "4. Run ioping custom tests"
	echo "5. Exit"
	echo "-----------------------------------------"
 
	read -p "Enter option [ 1 - 5 ] " option
	echo "-----------------------------------------"
 
case "$option" in
1)
 
funct_install
 
;;
2)
 
funct_install
 
;;
3) 
 
if [ -f /usr/local/bin/ioping ]; then
 
	if [ -f /etc/rc.d/init.d/vzquota -o -f /proc/user_beancounters ]; then
 
	echo "Virtuzzo OR OpenVZ Virtualisation detected"	
 
	funct_vztest
 
	else
 
	funct_test
 
	fi
 
else
 
	echo "ioping not installed. To manually install, run ./ioping.sh install"
	echo ""
 
	read -p "Want to install ioping ? [y/n]: " -t30 askinstall;
 
	if [ "$?" != "0" ]; then
		echo ""
		echo "You did not answer within 30 seconds. Exiting script..."
		exit 0
	fi
 
	if [[ "$askinstall" = [yY] ]]; then
 
	funct_install
 
	else
 
	exit 0
 
	fi
 
fi
 
;;
4)
 
if [ -f /usr/local/bin/ioping ]; then
 
	if [ -f /etc/rc.d/init.d/vzquota -o -f /proc/user_beancounters ]; then
 
	echo "Virtuzzo OR OpenVZ Virtualisation detected"	
 
	funct_vzcustomtests
 
	else
 
	funct_customtests
 
	fi
 
else
 
	echo "ioping not installed. To manually install, run ./ioping.sh install"
	echo ""
 
	read -p "Want to install ioping ? [y/n]: " -t30 askinstall;
 
	if [ "$?" != "0" ]; then
		echo ""
		echo "You did not answer within 30 seconds. Exiting script..."
		exit 0
	fi
 
	if [[ "$askinstall" = [yY] ]]; then
 
	funct_install
 
	else
 
	exit 0
 
	fi
 
fi
 
;;
5)
 
echo ""
echo "exit"
exit 0
 
;;
*)
 
echo "$0 1 - install"
echo "$0 2 - reinstall"
echo "$0 3 - default tests"
echo "$0 4 - custom tests"
 
;;
esac
 
done
 
exit

来源:http://vbtechsupport.com/1239/

        http://code.google.com/p/ioping/

发表留言

人生在世,错别字在所难免,无需纠正。