msgbartop
Tips and Tricks site for advanced HP-UX Engineers
msgbarbottom

01 Jul 10 Quick and dirty awk trick to see all Fiber Channel status

I needed to update documentation and I needed more information that my prior syslayout.sh script provided on fiber.

# Improvement by JRF on the ITRC forums.

ioscan -kfnC fc | awk ‘/fcd/ {getline;fcd=$NF;print fcd,$2}’ | while read -r fdev
do

fcmsutil ${fdev} | awk ‘/Hardware / {print $5};/World / { print $7}’

done

Ouput looks like this:

0/0/12/1/0/4/0
0x5001438002a24979
0x5001438002a24978
0x204f000dec81b540
0x200f000dec81b541

0/0/12/1/0/4/1
0x5001438002a2497b
0x5001438002a2497a
0x2093000dec81b480
0x2010000dec81b481

2/0/12/1/0/4/0
0x5001438002a24d35
0x5001438002a24d34
0x2050000dec81b480
0x2010000dec81b481

2/0/12/1/0/4/1
0x5001438002a24d37
0x5001438002a24d36
0x2093000dec81b540
0x200f000dec81b541

Second, new improved version (Girsah Chadash)
ioscan -kfnC fc | awk ‘/fcd/ {getline;fcd=$NF;print fcd,$2}’ | while read -r fde
v
do

fcmsutil ${fdev} | awk ‘/Hardware / {print $5};/World / { print $7}’ | awk’ {printf “%s %s %s %s %s”,$1, $2, $3, $4, $5;}’
fcmsutil ${fdev} | awk ‘/Hardware Path/ {PATH=$5};
/N_Port Node/ {NNODE=$7};
/N_Port Port/ {NPORT=$7};
/Switch Port/ {SPORT=$7};
/Switch Node/ {SNODE=$7};
END{print PATH, NNODE, NPORT, SPORT, SNODE}’

done

Next innovation would be to combine the awk statements in the while loop and pull off the output with a single awk command. I may do this, but I might need help from an awk guru.

The ioscan output is multi line, so the real innovation is using the getline function of awk to get the second line of data and ignore the first. The filter /fcd gets rid of the column format information.

Yes it could be done with grep, but it is more AWKFUL this way.

Updated document to provide some indentation. Trying to make the code easier to read. That may force me to add formatted scripts to download, which I will get to as time permits.

SEP

Tags: , ,

Leave a Comment

You must be logged in to post a comment.

WhatsApp chat