LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2016, 04:49 AM   #1
limdel
Member
 
Registered: May 2009
Location: Ho Chi Minh City, Vietnam
Distribution: CentOS - FEDORA
Posts: 59

Rep: Reputation: 15
script to test IOPS on multiple mounted disk


Hi,
My goal is to have a single script that would output something like this:
Code:
sas15kr1001-1 =197 MB/s
sas15kr1001-16 =209 MB/s
on several disk by running the 2 following commands
Code:
dd if=/dev/zero of=/sas15kr1001/test.io bs=64k count=1k conv=fdatasync
dd if=/dev/zero of=/sas15kr1001/test.io bs=64k count=16k conv=fdatasync
where sas15kr1001 is the mount point of a disk and "1" and "16" is the number thousand block of 64k written on the disk.
So i wrote this script
Code:
#!/bin/bash
adisk=( sas15kr1001 sas10kr501 sas15kr502 r10a r10b )
for i in "${adisk[@]}"
do
#       echo $i
        acount=( "1" "16" )
        for c in "${acount[@]}"
        do
                dd if=/dev/zero of=/`$i`/test.io bs=64k count=`$c`k conv=fdatasync 2>&1 |& awk '/copied/ {print "'$i'- '$c'=" $8 " "  $9}'
        done
done
While the command
Code:
dd if=/dev/zero of=/sas15kr1001/test.io bs=64k count=1k conv=fdatasync  2>&1 |& awk '/copied/ {print "sas15kr1001-1=" $8 " " $9}'
return
Code:
sas15kr1001-1=181 MB/s
when i run the script, the output is quite weird
Code:
./testio.sh
./testio.sh: line 9: sas15kr1001: command not found
./testio.sh: line 9: 1: command not found
sas15kr1001- 1=188 MB/s
./testio.sh: line 9: sas15kr1001: command not found
./testio.sh: line 9: 16: command not found
sas15kr1001- 16=200 MB/s
any one can point me where i get it wrong ?
Cheers

Last edited by limdel; 12-17-2016 at 04:51 AM.
 
Old 12-17-2016, 05:42 AM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I think you must change the tick marks to quotes. Ticks indicate the output of a command. `ls` is the output of ls.
 
1 members found this post helpful.
Old 12-17-2016, 06:21 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,794

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Yes, backticks run their contents as a subshell i.e. shell commands.
If not yet in quotes, quote the variables
Code:
of=/"$i"/test.io bs=64k count="$c"k
If they are in quotes already you might need to { } them
Code:
"of=/$i/test.io" bs=64k "count=${c}k"
--
Why array variables?
Code:
#!/bin/bash
for i in sas15kr1001 sas10kr501 sas15kr502 r10a r10b
do
#       echo $i
        for c in 1 16
        do
...
Array variables make sense if you want to do complex operations on the elements, like removing/inserting/rearranging/changing them.
 
1 members found this post helpful.
Old 12-18-2016, 08:33 PM   #4
limdel
Member
 
Registered: May 2009
Location: Ho Chi Minh City, Vietnam
Distribution: CentOS - FEDORA
Posts: 59

Original Poster
Rep: Reputation: 15
Thank you guys for your valuable feedback.
Here the final script for further ref.
Code:
#!/bin/bash
for i in sas15kr1001 sas10kr501 sas15kr502 r10a r10b
do
#       echo $i
	for c in 1 16
	do
		siz=`expr $c \* 64000`
		dd if=/dev/zero of=/"$i"/test.io bs=64k count="$c"k conv=fdatasync 2>&1 |& awk '/copied/ {print "'$i' \t '$siz' \t " $8 " "  $9}'
	done
done
 
Old 12-19-2016, 07:24 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,794

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Bash's builtin arithmetic is as good as the one in expr, but much more efficient.
Replace
Code:
		siz=`expr $c \* 64000`
by
Code:
		siz=$(( c * 64000 ))
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate MAX IOPS of a disk vicky007aggrwal Linux - Newbie 9 12-18-2018 11:19 AM
Disk iops manoj.linux Linux - Hardware 2 09-20-2013 02:14 PM
Calculating DISK IOPS. manoj.linux General 2 09-16-2013 10:26 PM
[SOLVED] Script For sending mail if disk is not mounted Vi_rod Linux - Newbie 22 12-15-2011 05:18 AM
How to test is a drive is mounted in a shell script? agtlewis Linux - General 7 03-18-2009 09:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration