basically tech

111 sed and iostat

Saturday 22nd November, 2008

This tip is specifically for the version of sed which came with Solaris. GNU sed has options which make solving this problem much easier.
Rob. April 2015.

I'm sure many Solaris admins will have come across this problem before. You have a SAN-attached host with dozens, maybe even hundreds of visible LUNs. Each LUN has a highly improbable and unwieldy name, as some of these SAN-attached devices do, and you need the iostat data for that LUN.

grep is no help, because you also want the four lines of data beneath the 'disk' name.

Well, you could just run iostat and painstakingly trawl through hundreds of lines of data, searching for the information you need. Or you could use the goodness of sed to find your LUN, and the four lines of data beneath it ...

$ iostat -En | sed -n '/c4t60060480000290101035533030433430d0/{p;n;p;n;p;n;p;n;p;}'

c4t60060480000290101035533030433430d0 Soft Errors: 0 Hard Errors: 1223 Transport Errors: 1170
Vendor: EMC      Product: SYMMETRIX        Revision: 5771 Serial No:
Size: 54.41GB <54408314880 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 75 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0

And that is a genuine LUN id!