I am trying to parse multipath output on linux for the script I am writing and I cannot find the correct SED or AWK syntax to get it the way I want it. I have looked at various sites and stackoverflow examples many times.
I want to find a way to do:
temp (360a98000572d4d2d5834566c64536b46) dm-4 NETAPP,LUN [size=20G] 2:0:0:4 sde 8:64 [active][ready] 1:0:0:4 sdm 8:192 [active][ready] redo (360a98000572d4d2d5834566c646c366c) dm-3 NETAPP,LUN [size=5.0G] 2:0:0:3 sdd 8:48 [active][ready] 1:0:0:3 sdl 8:176 [active][ready]
look like this:
temp (360a98000572d4d2d5834566c64536b46) dm-4 NETAPP,LUN [size=20G] 2:0:0:4 sde 8:64 active][ready] temp (360a98000572d4d2d5834566c64536b46) dm-4 NETAPP,LUN [size=20G] 1:0:0:4 sdm 8:192 [active][ready] redo (360a98000572d4d2d5834566c646c366c) dm-3 NETAPP,LUN [size=5.0G] 2:0:0:3 sdd 8:48 [active][ready] redo (360a98000572d4d2d5834566c646c366c) dm-3 NETAPP,LUN [size=5.0G] 1:0:0:3 sdl 8:176 [active][ready]
** Edit So, having made this even more difficult, I found multipath configurations without Netapp default settings. This makes NETAPP, LUN not guaranteed to be on line. What I started to do:
/sbin/multipath -ll | grep -v "round-robin"| sed 's/\[feat.*//g' | sed ':a; $!N;s/\n\([^\n]*\[size\)/ \1/;ta;P;D'
which puts the size on the main line to give me something else:
360a98000572d4d2d5834664e68323436 dm-6 NETAPP,LUN [size=50G] \_ 1:0:0:0 sda 8:0 [active][ready] 360a98000572d4d2d5834664e68395951 dm-7 NETAPP,LUN [size=275G] \_ 1:0:0:7 sdb 8:16 [active][ready]
However, I cannot get any of the examples below to match "G [$" (I know that I will need another line for T if there are volumes of volumes on terabytes) and give me the correct output.
Thanks for all the suggestions below ** Finish editing
I know how to clear the interval, so I will do it after I get the correct result. Lines that start multipath information end with "LUN." Servers can have 1 to 8 paths under each LUN line (sdx devices). The part before "()" can be either text (alias) or numeric.