1833877 Members
1644 Online
110063 Solutions
New Discussion

ioscan format

 
Shahul
Esteemed Contributor

ioscan format

Hi,

I am doing #ioscan -funC tape on my server, and I get the following output.

Class I H/W Path Driver S/W State H/W Type Description
==========================================================================
tape 39 0/2/0/0.22.0.255.0.6.0 atdd CLAIMED DEVICE IBM ULT3580-TD3
/dev/rmt/39m /dev/rmt/39mnb /dev/rmt/c151t6d0BESTn
/dev/rmt/39mb /dev/rmt/c151t6d0BEST /dev/rmt/c151t6d0BESTnb
/dev/rmt/39mn /dev/rmt/c151t6d0BESTb
tape 46 0/2/0/0.22.0.255.0.7.0 atdd CLAIMED DEVICE IBM ULT3580-TD3
/dev/rmt/46m /dev/rmt/46mnb /dev/rmt/c151t7d0BESTn
/dev/rmt/46mb /dev/rmt/c151t7d0BEST /dev/rmt/c151t7d0BESTnb
/dev/rmt/46mn /dev/rmt/c151t7d0BESTb
tape 27 0/2/0/0.22.0.255.1.0.0 atdd CLAIMED DEVICE IBM ULT3580-TD3
/dev/rmt/27m /dev/rmt/27mnb /dev/rmt/c152t0d0BESTn
/dev/rmt/27mb /dev/rmt/c152t0d0BEST /dev/rmt/c152t0d0BESTnb
/dev/rmt/27mn /dev/rmt/c152t0d0BESTb
tape 37 0/2/0/0.22.0.255.1.1.0 atdd CLAIMED DEVICE IBM ULT3580-TD3
/dev/rmt/37m /dev/rmt/37mnb /dev/rmt/c152t1d0BESTn
/dev/rmt/37mb /dev/rmt/c152t1d0BEST /dev/rmt/c152t1d0BESTnb
/dev/rmt/37mn /dev/rmt/c152t1d0BESTb
tape 38 0/5/0/0.22.0.255.0.10.0 atdd CLAIMED DEVICE IBM ULT3580-TD3
/dev/rmt/38m /dev/rmt/c150t10d0BEST
/dev/rmt/38mb /dev/rmt/c150t10d0BESTb
/dev/rmt/38mn /dev/rmt/c150t10d0BESTn
/dev/rmt/38mnb /dev/rmt/c150t10d0BESTnb
tape 44 0/5/0/0.22.0.255.0.11.0 atdd SCAN DEVICE IBM ULT3580-TD3
/dev/rmt/44m /dev/rmt/c150t11d0BEST
/dev/rmt/44mb /dev/rmt/c150t11d0BESTb
/dev/rmt/44mn /dev/rmt/c150t11d0BESTn
/dev/rmt/44mnb /dev/rmt/c150t11d0BESTnb

You can see here, some of the dvices have 3 columns of device files and some has two columns. And this behaviour is not persistent, it changes. Sometimes, all of them listed in 3 columns. Because of this inconsistency, my scripts are picking wrong fields. Could someone tell me how can I make sure ioscan lists devices in same format each time?
12 REPLIES 12
Shahul
Esteemed Contributor

Re: ioscan format

As the ioscan list removed all the tabs here, I will clarify that, last two tape devices has two columns of device files and all the rest have 3 columns.
Suraj K Sankari
Honored Contributor

Re: ioscan format

Hi,
>>my scripts are picking wrong fields.

Can you let me know which fields you are picking from your script.

Suraj
Shahul
Esteemed Contributor

Re: ioscan format

Hi,

FDor example, if you take first TWO devices, I need to pick something like this.

39mnb 151 6 0
46mnb 151 7 0

See, I can get around the problem by grepping and filtering,etc from ioscan output. But it will be easy, if ioscan lists all tape devices in same format everytime. I can't see a reason why ioscan should list differently, because all tape devices have got same number of devices, same sort of FC paths. May be something to do with the terminal window size, but probably there is a way to fix that.

Re: ioscan format

I doubt its down to terminal window sizes, as if you are using it in a shell pipeline, the stdout of ioscan isn't attached to a terminal anyway. More likely down to some fixed width calculations in ioscan - note that last two entries in the example you have have a slightly longer length - this probably means that the text formatter on the output for ioscan determines there isn't enough space to fit in another column.

I guess one of our awk or perl gurus should be ablt to give you a method of getting this output 100% consistent (maybe just one device file per line?)

However, what about approaching the problem from a different direction:

lssf /dev/rmt/*mnb | grep -v '???'

will give you a list of valid devices and hardware paths for the /dev/rmt/Xmnb devices, and:

lssf /dev/rmt/c*t*d*BESTnb | grep -v '???'

will get you a similar list - now you just need to compare hardware paths between the 2 outputs to match up. The output of lssf is much more consistent.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Suraj K Sankari
Honored Contributor

Re: ioscan format

Hi,

Here is the script

ioscan -fnC tape >/tmp/data
awk '{if (substr($0,13,2)==" /")
{
a=substr($0,23,5)
b=substr($0,39,3)
c=substr($0,43,1)
print a" "b" "c
}
}'
copy this lines into a file
sh myfile

39mnb 151 6
46mnb 151 7
27mnb 152 0
37mnb 152 1

Suraj

Suraj K Sankari
Honored Contributor

Re: ioscan format

Hi,
Forget to print the last 0 as said by you last field be always 0 (Zero)

Insted of this line
print a" "b" "c

use this line
print a" "b" "c" "0

output will be
39mnb 151 6 0
46mnb 151 7 0
27mnb 152 0 0
37mnb 152 1 0

Suraj


Shahul
Esteemed Contributor

Re: ioscan format

Hi Suraj,

I have tried that, didn't work. if I read it correctly, Your script is again depends on the charecter positions in ioscan output and the number of charecters on the output. If that is the case it doesn't work, because ioscan output changes each time. for eg. I have ran an #ioscan -funC tape now, it is showing all the devices in 3 columns. My logic is working when all the devices are listed in 3 columns, it breaks when the format changes.

awk '{if ($0~/tape/){gsub(/\./," ");id1=$8; id2=$9;} else if($0~/mnb/){gsub(/\//," ");sub(/c/,"");sub(/t[0-9]/," ");print $6, $9, id1, id2}}'

I am really looking for why ioscan shows one format in the morning, another format in the afternoon.

TIA
Shahul

Re: ioscan format

ok, I take it back - ioscan *does* pay attention to terminal settings!

Some quick playing around showed that if you adjust the COLUMNS environment variable, it changes the output of ioscan.

So try running:

export COLUMNS=4096
ioscan -funC tape

Rememeber to reset COLUMNS appropriately after the ioscan is run.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Shahul
Esteemed Contributor

Re: ioscan format

Thanks Duncan,

I agree. I have tried COLUMNS=80 & COLUMNS=100, and the output shows different. So, for the timebeing I have added this variable in the script and slightly adjusted the fields in awk. So, it is working, but not sure howlong. Because it is being working for sometime and then broken, fixed,broken... So, will keep quiet now until it breaks next time.

Thanks
Shahul
OldSchool
Honored Contributor

Re: ioscan format

why don't you use the "compact" format option. It produces fields delimited by ":" and no extraneous spaces. I'd think think that'd be easier to reliably parse.....

something like "ioscan -FunC tape"????

Re: ioscan format

OldSchool,

Probably cos the lines he's interested in aren't effected by the "-F" option - that does compact all the output *except* for the device file information, which is still displayed on seperate lines

HTH

Duncan


I am an HPE Employee
Accept or Kudo
OldSchool
Honored Contributor

Re: ioscan format

Duncan: "compact all the output *except* for the device file information"

ahh..wasn't aware of that....should've looked..thanks for the info