LinuxQuestions.org
Help answer threads with 0 replies.
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 11-20-2015, 06:25 AM   #16
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002

Quote:
Originally Posted by applehalf View Post
awk '/MY_STORAGE_NAME/{print gensub(/[()]/,"","g")}' is very nice decision.
Ok once more time.
For example command iostat -kNx result is:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm util
sdc 0.00 0.00 0.00 0.00 0.00 0.00 10.77 0.00 1.80 1.78 0.00
sdt 0.00 0.00 0.00 0.00 0.00 0.00 10.98 0.00 0.56 0.54 0.00
sdg 0.00 0.00 0.00 0.00 0.00 0.00 10.56 0.00 1.19 1.18 0.00
sdx 0.00 0.00 0.00 0.00 0.00 0.00 11.12 0.00 20.51 0.51 0.00
sdk 0.00 0.00 0.00 0.00 0.00 0.00 11.31 0.00 0.73 0.73 0.00
sdab 0.00 0.00 0.00 0.00 0.00 0.00 11.00 0.00 30.66 0.64 0.00
sdo 0.00 0.00 0.00 0.00 0.00 0.00 11.38 0.00 0.87 0.86 0.00
sdaf 0.00 0.00 0.00 0.00 0.00 0.00 10.52 0.00 0.78 0.78 0.00

DISK5 (UUID_OF_DISK5) dm-1 FUJITSU,ETERNUS_DX8000
size=4.0T features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=130 status=active
|- 2:0:15:2 sdc 8:32 active ready running
|- 3:0:12:2 sdt 65:48 active ready running
|- 2:0:16:2 sdg 8:96 active ready running
|- 3:0:15:2 sdx 65:112 active ready running
|- 2:0:17:2 sdk 8:160 active ready running
|- 3:0:20:2 sdab 65:176 active ready running
|- 2:0:18:2 sdo 8:224 active ready running
`- 3:0:21:2 sdaf 65:240 active ready running

I see that 2 pathes of one disk have await more than 10, so I want to recieve information about DISK5 (but only once, because if I have 20 disks with 16 paths each, and 10 disks have await much then 10 in all pathes, then I want to recieve 10 rows instead of 160).
A single line solution (not tested at all):
Code:
iostat 1 2 $(multipath -ll dm-1|grep running|cut -d' ' -f3) | awk '$10>0 { print "path",$1,"wait time",$10 }'
Disadvantage: It takes 2 secs per device.

Last edited by berndbausch; 11-20-2015 at 06:31 AM.
 
Old 11-20-2015, 06:31 AM   #17
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by berndbausch View Post
A single line solution (not tested at all):
Code:
iostat 1 2 $(multipath -ll dm-1|grep running|cut -d' ' -f3) | awk '$10>0 { print "path",$1,"wait time",$10 }'
Oops I understand now that you only want one line for dm-1. Then just feed the name of dm-1 into awk. When awk finds a line with await>10, it will print "dm-1" and stop processing.
 
Old 11-22-2015, 11:53 PM   #18
applehalf
Member
 
Registered: Oct 2013
Posts: 33

Original Poster
Rep: Reputation: Disabled
iostat for each path of each disk?
I think it will take more time, than 5 sec.
 
Old 11-23-2015, 12:18 AM   #19
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by applehalf View Post
iostat for each path of each disk?
I think it will take more time, than 5 sec.
Run iostat 1 2 once for all disks, saving its output to a file, then modify my one-liner, e.g.
Code:
grep $(multipath -ll dm-1|grep running|cut -d' ' -f3) iostat.output | awk '$10>0 { print "path",$1,"wait time",$10 }'
 
Old 11-23-2015, 01:06 AM   #20
applehalf
Member
 
Registered: Oct 2013
Posts: 33

Original Poster
Rep: Reputation: Disabled
awk is better than cut:
-bash-4.1$ sudo multipath -a DISK_UUID -ll
DISK1 (DISK1_UUID) dm-3 MY_STORAGE_NAME
size=4.0T features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=130 status=active
|- 2:0:18:3 sdd 8:48 active ready running
|- 3:0:6:3 sdy 65:128 active ready running
|- 2:0:20:3 sdi 8:128 active ready running
|- 3:0:13:3 sdad 65:208 active ready running
|- 2:0:21:3 sdn 8:208 active ready running
|- 3:0:27:3 sdai 66:32 active ready running
|- 2:0:22:3 sds 65:32 active ready running
`- 3:0:29:3 sdan 66:112 active ready running
-bash-4.1$ sudo multipath -a DISK1_UUID -ll |grep running |awk '{print $3}'
sdd
sdy
sdi
sdad
sdn
sdai
sds
sdan
-bash-4.1$ sudo multipath -a DISK1_UUID -ll |grep running|cut -d' ' -f5
sdd

sdi
sdad
sdn
sdai
sds
sdan
-bash-4.1$ sudo multipath -a DISK1_UUID -ll |grep running|cut -d' ' -f6

sdy

65:208

66:32

66:112
 
Old 11-23-2015, 05:07 AM   #21
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
It looks like you're on the way to success, great!

I had not taken the successive blanks into account, which cut considers separate fields. While you could have used sed to compress sequences of blanks into a single blank, the awk solution looks more natural to me. Good job!
 
  


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
[SOLVED] Why this script do not cycle? postcd Programming 4 11-28-2013 08:43 AM
The Cycle of Minimalism jarubyh General 11 02-11-2012 06:54 PM
fetch execute cycle Gogul General 4 02-09-2006 08:55 AM
Deep Cycle for RH9 Mad Mardigan Linux - Laptop and Netbook 1 12-26-2005 10:22 PM
Release Cycle? ubuntu-addict SUSE / openSUSE 12 11-17-2004 02:55 PM

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

All times are GMT -5. The time now is 10:00 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