mapgfs command

 


#!/bin/ksh

## This command simply maps powerdisk devices to filesytem names
## and nsd devices and then runs the mmlsdisk command for each
## If you aren't using emc, change DISKEXCLUDE


function callMmlsdisk {

# Run mmlsdisk and lspv for each record and merge the results

/usr/lpp/mmfs/bin/mmlsdisk $DEVICE | grep nsd | while read NSD RESTOFLINE
   do
   lspv | grep $NSD | grep $DISKEXCLUDE
   echo $RESTOFLINE
   done | xargs -n 10 | awk '{print $1,"\t",$6,"\t",$3}'
}

# Initial variables

TEMPFILESYSTEMS=/tmp/$$filesystems
FILESYSTEMRECORD=/tmp/$$fsrecord
DISKEXCLUDE=power

# Create a mmfs only version of /etc/filesystems

grep -p "= mmfs" /etc/filesystems > $TEMPFILESYSTEMS

# Now create a format which grabs two lines and merges them down to one line
# here is an example:
# /dir/dbf: dev = /dev/dbf1
# /dir/log: dev = /dev/log1
# /dir/sys: dev = /dev/sys1

egrep ":|/dev" $TEMPFILESYSTEMS | xargs -n4 > $FILESYSTEMRECORD

# Use only the first and last line, loop to print

awk '{ print $1,$4}' $FILESYSTEMRECORD | while read FSNAME DEVICE
     do
       echo  # space to divide records
       echo $FSNAME ---FG------NSD---------   # Heading
       callMmlsdisk $DEVICE
     done

# Remove temporary files
rm $TEMPFILESYSTEMS $FILESYSTEMRECORD

Leave a Reply

Your email address will not be published. Required fields are marked *