metatree - pretty print Solstice DiskSuite metadevice configuration

To view the entire configuration for all Solstice DiskSuite metadevices we used the metastat -p command to generate the output. The output is bland.

% metastat -p
d3 -m d13 d23 1
d13 1 1 c1t0d0s3
d23 1 1 c1t2d0s3
d1 -m d11 d21 1
d11 1 1 c1t0d0s1
d21 1 1 c1t2d0s1
d0 -m d10 d20 1
d10 1 1 c1t0d0s0
d20 1 1 c1t2d0s0

However, if we parse the metastat -p output with a little awk script the output can look more pleasing on the eyes. For example:

% metatree
d10 -m d11 d12 1
   d11 1 1 c1t0d0s0
   d12 1 1 c1t1d0s0
d20 -m d23 d22 1
   d22 1 1 c1t1d0s1
   d23 1 1 c1t0d0s1
d30 -m d31 d32 1
   d31 1 1 c1t0d0s3
   d32 1 1 c1t1d0s3
d40 -m d41 1
   d41 1 1 c1t0d0s4
d42 1 1 c1t1d0s4
d50 -m d51 1
   d51 1 1 c1t0d0s5
d52 1 1 c1t1d0s5
d530 -p d60 -o 33564672 -b 2097152
d535 -p d60 -o 35661856 -b 1024000
d60 -m d61 d62 1
   d61 1 1 c1t2d0s6
   d62 1 1 c1t3d0s6
d65 -p d60 -o 10208 -b 33554432
d70 -m d71 1
   d71 1 1 /dev/dsk/emcpower0a
d80 -m d81 1
   d81 1 1 /dev/dsk/emcpower3a
d85 -p d80 -o 2592 -b 52428800
d90 -m d91 1
   d91 1 1 /dev/dsk/emcpower2a
 

The script

Below is a simple awk script which simply indents the metastat output:

metastat -p | \
awk '
   $2 == "-m" { print; tcount=NF -3 next;}
   NF == 4 && $4 ~ /^d/ {tcount++ ;}
   {
      if(tcount>0){
         printf(" "); tcount=tcount-1;
      }
      print;
   }'

If you don't fancy copy'n'paste the about, you can download the script from here