Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script in AIX for rmt's

Posted on 2010-09-08
8
Medium Priority
?
2,258 Views
Last Modified: 2013-11-17
Hi  

 I need a script in AIX which should show the rmt's ,serial number of tape,HBA attached. in following format.

rmt  from aix end | serial no of drive | HBA adapter

Ex:
rmt34567  | 0345678654 | fcs


 
0
Comment
Question by:ibmsddk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33630558
Hi,

#!/bin/ksh
lsdev |grep fscsi | while read FSCS rest
  do
    TAPES=$(lsdev -p $FSCS | grep rmt | grep -v ALT |cut -f1 -d" ")
      for TAPE in $TAPES
        do
          SERIAL=$(lscfg -vl $TAPE | grep Serial | awk -F"." '{printf "%d", $NF}')
          FCS=$(echo $FSCS | sed 's/fscsi/fcs/')
          echo $TAPE "|" $SERIAL "|" $FSCS "|" $FCS
        done
  done

Some remarks:

1) The script works on the protocol devices fscsix, not on the fibre channel adapters fcsx themselves,
because if there are multiple fcsx devices it's not quite simple to show the actual parent fcsx of a given fscsix.
But given the fact that for e.g. fscsi0 it's always fcs0, the script does a simple change to display the
fcs device additionally. Remove either $FSCS or $FCS from the "echo" line if you don't want to see both.

2) If you have multi-homed drives with "alt_pathing=yes" being set, there will be an alternate device ("ALT") for any multipathing-enabled primary device ("PRI"). Since I don't know if this is the case for you I excluded the ALT devices in the script (thus "grep -v ALT).


wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33632003
Just for fun - try this to get "the whole picture":

#!/bin/ksh
lsdev |grep fscsi | while read FSCS rest
  do
    lsdev -p $FSCS | grep rmt |while read TAPE filler LOC MODEL
        do
          SERIAL=$(lscfg -vl $TAPE | grep Serial | awk -F"." '{printf "%d", $NF}')
          ALT=$(echo $LOC | awk -F"-" '{print $4}')
          FCS=$(echo $FSCS | sed 's/fscsi/fcs/')
          echo $TAPE "|" $SERIAL ${ALT:-"   "} "|" $FSCS "|" $FCS "|" "$MODEL"
        done
  done |sort -k3,n
0
 

Author Comment

by:ibmsddk
ID: 33640158
Assuming that  i'm using 1 drive and connected to 3HBA so it produces 3 rmt's

in below format

rmtname|  serialno | fcs| statefrom os end
rmt12345 | 23455 |fcs1 |available or defined
rmt*|23455|fcs2|available
rmt*|23455|fcs1|available

so i can know all same tapes and logical rmt's belong to single drive and availability in os end.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33640621
So where is the problem? Seems that you didn't even run my scripts!

My second version does not only give you the 'PRI' or 'ALT' flags following the serial, it's also sorted by this serial number, so you could easily see which drives are identical.

As a goodie the verbose device description is shown.

OK, you don't want to see the protocol device, no problem. Instead, you're requesting the 'Available' or 'Defined' states, which was not part of your original question.

Anyway -

#!/bin/ksh
echo "rmt  | Serial  A/P | HBA  | State"
echo "-------------------------------------"
lsdev |grep fscsi | while read FSCS rest
  do
    lsdev -p $FSCS | grep rmt |while read TAPE STATE LOC MODEL
        do
          SERIAL=$(lscfg -vl $TAPE | grep Serial | awk -F"." '{printf "%d", $NF}')
          ALT=$(echo $LOC | awk -F"-" '{print $4}')
          FCS=$(echo $FSCS | sed 's/fscsi/fcs/')
          echo $TAPE "|" $SERIAL ${ALT:-"   "} "|" $FCS "|" $STATE
        done
  done |sort -k3n,6


If you don't like the "PRI/ALT" stuff, remove the parts I marked in bold.
0
 

Author Comment

by:ibmsddk
ID: 33683356
hi

it works fine ,

rmt130801 | 7839298 PRI | fcs1 | Available
rmt230801 | 7839298 ALT | fcs2 | Available
rmt330801 | 7839298 ALT | fcs3 | Available
rmt430801 | 7839298 ALT | fcs5 | Available

thanks ..if i want WWN  how to add ,and also SMC needs to be displayed ,
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 33683550
Here is WWN -
#!/bin/ksh
echo "rmt  | Serial  A/P | WWN                | HBA  | State"
echo "-----+-------------+--------------------+------+----------"
lsdev |grep fscsi | while read FSCS rest
  do
    lsdev -p $FSCS | grep rmt |while read TAPE STATE LOC MODEL
        do
          SERIAL=$(lscfg -vl $TAPE | grep Serial | awk -F"." '{printf "%d", $NF}')
          WWN=$(lsattr -El $TAPE | grep node_name | awk '{print $2}')
          ALT=$(echo $LOC | awk -F"-" '{print $4}')
          FCS=$(echo $FSCS | sed 's/fscsi/fcs/')
          echo $TAPE "|" $SERIAL ${ALT:-"   "} "|" $WWN "|" $FCS "|" $STATE
        done
  done |sort -k3n,6
echo "-----+-------------+--------------------+------+----------"
But what do you mean with SMC?
0
 

Author Comment

by:ibmsddk
ID: 33698187
i mean the medium changers properties
0
 

Author Closing Comment

by:ibmsddk
ID: 33698220
problem solved
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question