Operating System - Linux
1829115 Members
13069 Online
109986 Solutions
New Discussion

Show disk ioscan in one line

 
SOLVED
Go to solution
nz_1
Advisor

Show disk ioscan in one line

I am trying to get ioscan output for disk to be shown in one line.

So far I managed to do as below and include it in my script.

/usr/sbin/ioscan -fnCdisk |grep -v "Class" |/usr/bin/awk '{print $1" "$5" "$6" "$7" "$8" "$2" "$3" "$4"="}'|/usr/bin/sed -e :a -e '/sdisk=/N; s/sdisk=\n//; ta' |/usr/bin/awk '{print $1":"$2":"$3":"$4":"$5":"$6":"$7":"$8":"$9}' |grep -v "="

However, this wont work if there is no device file for the hardware.

Anyone has a better solution?
Thanks.
Nash
8 REPLIES 8
Pete Randall
Outstanding Contributor
Solution

Re: Show disk ioscan in one line

I use the attached.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: Show disk ioscan in one line

Hi Nash:

When parsing the output of 'ioscan', using its '-F' option to produce colon-delimited fields eases the burden, particularly since missing fields are bounded by consecutive colons.

Regards!

...JRF...
nz_1
Advisor

Re: Show disk ioscan in one line

Hi James

Yes, -F option eases the burden but the the device files are still shown in a separate line.

Thanks.
nz_1
Advisor

Re: Show disk ioscan in one line

Hi Pete

I will find myself an awk book.

Thanks.

p.s. Next task - combine vgdisplay, diskinfo and ioscan
Ralph Grothe
Honored Contributor

Re: Show disk ioscan in one line

I'm not sure what sort of output you desire.
But extracting the disks' paths is quite simple (piped to head for brevity)


$ /usr/sbin/ioscan -kFdsdisk|awk -F: '/CLAIMED/&&!/DVD|CD|SUBDISK/{print$11}'|head
0/0/1/1.2.0
0/0/2/0.0.0
0/0/2/0.2.0
0/10/0/0.107.21.19.0.0.0
0/10/0/0.107.21.19.0.0.1
0/10/0/0.107.21.19.0.0.2
0/10/0/0.107.21.19.0.0.3
0/10/0/0.107.21.19.0.0.4
0/10/0/0.107.21.19.0.0.5
0/10/0/0.107.21.19.0.0.6
Madness, thy name is system administration
James R. Ferguson
Acclaimed Contributor

Re: Show disk ioscan in one line

Hi (again) Nash:

Output using awk uses a space as the default field separator. Hence:

# echo "1 2 3"|awk '{print $1" "$2" "$3}'

...is better written as:

# echo "1 2 3"|awk '{print $1,$2,$3}'

The comma indictes the interposition of the output separator.

You can change the default space separtor to any character you need by setting the OFS value like this:

# echo "1 2 3"|awk 'BEGIN{OFS="."};{print $1,$2,$3}'

...which produces the output:

1.2.3

A free, very nice tutorial to 'awk' can be found here:

http://www.gnu.org/software/gawk/manual/gawk.html

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: Show disk ioscan in one line

If you need to convert the HW paths of the disks which are easily retreivable through ioscan's -F switch, as shown above, I am afraid you need to do a little scripting.
The controller or card No. (well the digits after the c in /dev/dsk/c?t?d?) can be taken from the instance Nos. that ext_bus class like

$ /usr/sbin/ioscan -kFCext_bus|awk -F: '$10~/fcparray|c720/{printf"%2d %s\n",$13,$11}'
0 0/0/1/0
1 0/0/1/1
2 0/0/2/0
3 0/0/2/1
11 0/10/0/0.107.21.19.0
4 0/12/0/0.117.6.19.0


The target and device or lun part is simply the last to period delimited digits of the disk paths' from my first posting.

But don't despair, the Solaris device tree even sucks more ;-)

HTH
Madness, thy name is system administration
nz_1
Advisor

Re: Show disk ioscan in one line

Thank you all for the feedback. Here is my primitive script.
Nash