Operating System - HP-UX
1836987 Members
2290 Online
110111 Solutions
New Discussion

Re: HW path to special device file mapping

 
Ralph Grothe
Honored Contributor

HW path to special device file mapping

Hello,

I have to check for every disk of our various storage subsystems (which sum up to a few hundred disks) the timeout value of the physical volume, and if necessary set it to 60 secs for Comparex disks and 120 secs for EMC disks (manufacturer recommendations).
Since there are so many disks to check and possibly to adjust I would like to do this by script.

Thus I'm now looking for a way to translate/map the HW path to the special device file's name because the pvdisplay and pvchange commands only take device file names.
The mapping from device to HW path is quite easy because you only have to issue something like:

# lssf $(strings /etc/lvmtab|grep dsk)|awk '{print $NF, $(NF-1)}'

But I need exactly the inverse mapping.

I know I could parse the dump from ioscan (please, have a look at the attachment for a sample Perl scriplet I wrote), but I find this a bit much ado.
Especially because the output of the device files from the ioscan command when you use the -n flag is nasty, because it goes on an extra line, and you have to catch situations where there isn't an extra line at all (as I had done in the sample Perl script).

I'm sure there must be a single HP-UX command like lssf that does the reverse mapping without the need to parse ioscan dumps, which I only haven't come accross yet.
Madness, thy name is system administration
10 REPLIES 10
Tom Geudens
Honored Contributor

Re: HW path to special device file mapping

Hi Ralph
I could be missing the point here ... but what about :
# ioscan -kfnC disk|awk {'A=$1;B=$3;C=$7;D=$8;getline;E=$1;F=$2;print A,B,C,D,E,F}'
Class H/W State H/W =====================================================================
disk 8/4.5.0 HP C5447A /dev/dsk/c0t5d0 /dev/rdsk/c0t5d0
disk 8/4.5.1 HP C5447A /dev/dsk/c0t5d1 /dev/rdsk/c0t5d1
disk 8/4.5.2 HP C5447A /dev/dsk/c0t5d2 /dev/rdsk/c0t5d2
disk 8/4.5.3 HP C5447A /dev/dsk/c0t5d3 /dev/rdsk/c0t5d3
disk 8/4.5.4 HP C5447A /dev/dsk/c0t5d4 /dev/rdsk/c0t5d4
disk 8/4.5.5 HP C5447A /dev/dsk/c0t5d5 /dev/rdsk/c0t5d5
disk 8/4.5.6 HP C5447A /dev/dsk/c0t5d6 /dev/rdsk/c0t5d6
disk 8/4.5.7 HP C5447A /dev/dsk/c0t5d7 /dev/rdsk/c0t5d7
disk 8/16/5.2.0 TOSHIBA CD-ROM /dev/dsk/c2t2d0 /dev/rdsk/c2t2d0
disk 8/16/5.4.0 SEAGATE ST34573W /dev/dsk/c2t4d0 /dev/rdsk/c2t4d0
disk 8/16/5.6.0 SEAGATE ST32272N /dev/dsk/c2t6d0 /dev/rdsk/c2t6d0
A life ? Cool ! Where can I download one of those from ?
Tom Geudens
Honored Contributor

Re: HW path to special device file mapping

Hi again,
Oops, type in that ioscan ... even though it works :-). Should be :
ioscan -kfnC disk|awk '{A=$1;B=$3;C=$7;D=$8;getline;E=$1;F=$2;print A,B,C,D,E,F}'

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Stefan Farrelly
Honored Contributor

Re: HW path to special device file mapping

I think you want;

ioscan -fknH | grep dsk

eg. ioscan -fknH 10/0.6.0 | grep dsk
which returns;
/dev/dsk/c0t6d0 /dev/rdsk/c0td60
Im from Palmerston North, New Zealand, but somehow ended up in London...
Ralph Grothe
Honored Contributor

Re: HW path to special device file mapping

Tom,

thanks for your suggestion, but this also relies on parsing ioscan's output and glueing it together (nearly the same I achieve with my Perl snippet).
I had to look up the manpage of awk (prefer to use Perl ;-) to read what getline does.
As its name implies it only gets the next line from the file or piped command.
So your awk script would fail if the next output line from ioscan wasn't the related device file line.
This is what annoys me with ioscan's output of device files, because it is unreliable.
It'd be better if the developers of the ioscan program had supplied for an extra field in the ':' separated output of the -F flag.
Madness, thy name is system administration
James R. Ferguson
Acclaimed Contributor

Re: HW path to special device file mapping

Hi Ralph:

The '-F' option produces listing of fields separated by colons (:). This is quite useful for parsing with 'awk'. Missing fields are separated by consecutive colon characters. See the 'ioscan' man pages for more information.

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: HW path to special device file mapping

Stefan,

I also already had in mind the -H flag but imho it's far too costly, because I would have to invoke the command a hundred times, as it doesn't seem to be able to cope with several -H arguments.
See, it only gives me one match:

# ioscan -k -H 1/10/0/0.8.0.255.0.5.3 -H 1/10/0/0.8.0.255.0.5.4
H/W Path Class Description
=======================================================================
1/10/0/0.8.0.255.0.5.4 disk HITACHI OPEN-8*3


Sorry HP-UX developers, but I think in this respect the ioscan programm sucks ;-)
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: HW path to special device file mapping

James,

please, have a look a my attached little Perl ioscan parser.
I am using the -F flag already to make parsing easier.
I'm still convinced though, that the ioscan program has a few deficiencies.

HP-UX developers, how about a virtual /proc filesystem the way Linux offers it?
It's so easy to retrieve all your HW and process info from there
Madness, thy name is system administration
Tom Geudens
Honored Contributor

Re: HW path to special device file mapping

Hi Ralph,
I'm not giving up yet :-)
I had this same problem and solved it by using the script in the following thread
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x156c0b0717d1d5118ff40090279cd0f9,00.html

The 10 points answer by Robin should work for multiple (more than 1 line) devices.

Regards,
Tom

P.S. ... wow, James is early today ... Is it American time already :-)
A life ? Cool ! Where can I download one of those from ?
Ralph Grothe
Honored Contributor

Re: HW path to special device file mapping

Tom,

thanks for pointing me to the other thread.
Nice solution of Robin, but I think Perl is better fit for this purpose, and to be honest I want to avoid the struggle of looking up awk's "awk"ward syntax, when I could do it much easier in Perl.

My objective was only to find out about a neat HP-UX command that does the reverse of lssf, and avoids any parsing of ioscan dumps (which was made unecessarily difficult by the developers, see my above remarks)

Madness, thy name is system administration
James R. Ferguson
Acclaimed Contributor

Re: HW path to special device file mapping

Hi (again) Ralph & Tom:

Oops, you are indeed already using '-F'. I've read that wrong twice. I guess Tom's right, its early and I need more coffee ;-)

/no points/

Regards!

...JRF...