Please use script chk_dginfo for solving the VXVM related issues faster. It gives us all the important information like free disks, number of volumes/plexes, disk paths, which server DG is deported, free chunks in the disk, detailed subdisk information etc..
root# cat chk_dginfo
#!/usr/bin/ksh
# Script: chk_dginfo
# Usage: chk_dginfo [-Adfgmpqsv] <diskgroup list>
# chk_dginfo [-Adfgmpqsv] -G
# chk_dginfo [-gmq] -u
# chk_dginfo [-q] -S
# chk_dginfo -h
# chk_dginfo -V
# Exit codes: 0 = Execution without errors
# 1 = No valid diskgroup found on the system
# 2 = No valid diskgroup given as parameter
# ToDo: Option -l for link volume information (which volumes use SDs from this disk?)
# Option -G for complete disk geometry
###############################
### General preliminaries ###
###############################
# Home location of all used Veritas commands
VXDG=/usr/sbin/vxdg
VXPRINT=/usr/sbin/vxprint
VXDISK=/usr/sbin/vxdisk
# Before we begin: Is VERITAS Volume Manager available on this system at all?
$VXDG list >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
echo "WARNING (availability): VERITAS Volume Manager not available on this system!"
echo "exiting..."
exit 1
fi
# By default NO fancy graphics options
bon="" # `tput bold` = bold characters on
ion="" # `tput smso` = inverse characters on
bof="" # `tput rmso` = output back to normal (bold/inverse off)
# Temporary output files (in /tmp; will disappear after next reboot)
DLIST=/tmp/vxdisk_e_o_alldgs_list
DINFO=/tmp/vxdisk_list_dev
VLIST=/tmp/vxprint_dg_htqv
VLIS2=/tmp/vxprint_dg_htqv_vol
FLIST=/tmp/vxdg_dg_free
MLIST=/tmp/df_k.out
MPINF=/tmp/mpinf.out
SDINF=/tmp/sdinf.out
FCINF=/tmp/fcinf.out
PLINF=/tmp/plinf.out
# Process options
XINFO=1 # Disk info - 0: no; 1: yes (DINFO already reserved)
VINFO=1 # Volume info - 0: no; 1: yes
DSUBD=0 # Detailed subdisk info - 0: no; 1: yes
FRECH=0 # Free chunk info - 0: no; 1: yes
MULTI=0 # Multipath info - 0: no; 1: yes
PLEXI=0 # Plex and subdisk info - 0: no; 1: yes
UNASD=0 # Unassigned disks info - 0: no; 1: yes
ALLDG=0 # 0: use diskgroup list; 1: show info for ALL diskgroups
QUICK=0 # quick-run-option - 0: create new DLIST; 1: use old DLIST (if exists)
SMINF=0 # Summary information - 0: no; 1: yes
################################
### Process script options ###
################################
while getopts "AdfgGhlmpqsSuvV" OPT
do
case $OPT in
A) MULTI=1; DSUBD=1; FRECH=1; PLEXI=1
;;
d) VINFO=0 # No volume info since "disk info only"
;;
f) FRECH=1
;;
g) bon=`tput bold` # bold characters on
ion=`tput smso` # inverse characters on
bof=`tput rmso` # output back to normal (bold/inverse off)
;;
G) ALLDG=1
DGLIST=""
$VXDG list | grep -v "^NAME" | awk '{print $1}' | while read DG
do
DGLIST=$DGLIST" "$DG
done
;;
h) echo "usage: chk_dginfo [-Adfgmpqsv] <diskgroup list>"
echo " chk_dginfo [-Adfgmpqsv] -G"
echo " chk_dginfo [-gmq] -u"
echo " chk_dginfo [-q] -S"
echo " chk_dginfo -h"
echo " chk_dginfo -V"
echo
echo "function: display information on Veritas volume/disks in (blank separated) <diskgroup list>"
echo " or display information on Veritas volume/disks for ALL diskgroups on this system (-G)"
echo " or display information on unassigned Veritas disks (-u)"
echo " or display this help text (-h) and exit"
echo
echo " The information will be displayed in two separate sections:"
echo " 1) The disk info section - 2) The volume info section"
echo
echo "options: I - General options"
echo " -g: enable fancy graphics (feel free to try it out!)"
echo " -G: display information for ALL diskgroups imported on this system"
echo " -h: display this help text and exit"
echo " -q: quick-run-option: use old DLIST file (if exists)"
echo " -V: display version information and exit"
echo
echo " II - Disk info section options"
echo " -d: display disk info section only (skip volume information)"
echo " -f: display free chunk information"
echo " -m: display multipath information"
echo " -s: display detailed subdisk information"
echo
echo " III - Volume info section options"
echo " -p: display detailed volume (plexes and subdisks) information"
echo " -v: display volume info section only (skip disk information)"
echo
echo " IV - Special options"
echo " -A: display ALL information; equivalent to -fmps (both sections)"
echo " -u: display information on unassigned disks (neither section)"
echo " -S: display summary information for all disk groups (neither section)"
echo
echo "legend: NAME: Veritas disk name"
echo " ASSOC: Associated disk name"
echo " Native: Native (c#t#d#) disk name"
echo " #P: Number of enabled / total number of - paths to disk"
echo " #SD: Number of subdisks on this disk"
echo " Size: Capacity of disk in GigaBytes"
echo " Used: Used space on this disk in GigaBytes"
echo " Free: Free space on this disk in GigaBytes"
exit 0
;;
m) MULTI=1 # display multipath information
;;
p) PLEXI=1 # display detailed volume (plexes and subdisks) information
;;
q) QUICK=1 # quick-run-option
;;
s) DSUBD=1 # display detailed subdisk information
;;
S) SMINF=1 # display summary information for all diskgroups
;;
u) UNASD=1 # display information on unassigned disks
;;
v) XINFO=0 # No disk info since "volume info only"
;;
V) echo "Version=1.0 Date=2012/07/10 Opts=\"AdfgGhlmpqsSuvV\""
exit 0
;;
*) echo "This option is not supported and will be ignored."
;;
esac
done
shift `expr $OPTIND - 1`
# Create new or re-use old $DLIST file needed for ALL operations below
if [ "$QUICK" -eq 0 ]; then
$VXDISK -e -o alldgs list > $DLIST
else # [ "$QUICK" -eq 1 ]
ls $DLIST >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
echo "WARNING (quick-run): $DLIST does not exist; create new one"
$VXDISK -e -o alldgs list > $DLIST
fi
fi
#########################################
### Information on unassigned disks ###
#########################################
# If information on unassigned disks was requested, we're done quickly...
if [ "$UNASD" -eq 1 ]; then
echo
echo "Information on ${bon}unassigned${bof} disks"
# Determine width of Disk-Name-Column by finding longest diskname
WiD=4
awk '$4=="-" {print $1}' $DLIST | while read DNM
do
if [ "${#DNM}" -gt "$WiD" ]; then WiD=${#DNM}; fi
done
WjD=$(($WiD-4))
WkD=$(($WiD-5))
echo
# Output of dynamic first column of first row
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjD" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "Native #P Size State"
# Output of dynamic first column of second row
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "-------------------------- --- ------ --------"
awk '$4=="-" {print $1, $5, $6, $7}' $DLIST | while read DNM DST DNA DNL
do
# Determine number of devicepaths
$VXDISK list $DNM > $DINFO
grep -n "^numpaths:" $DINFO | awk -F: '{print $1, $NF}' | read LIN NPT
# $NPT is the number of paths - but how many of these are enabled?
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | grep -c "enabled" | read NEN
# Multipathing information - if desired
if [ "$MULTI" -eq 1 ]; then
if [ -w $MPINF ]; then rm $MPINF; fi
integer MPC=1 # Counter for number of (multi)paths
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | while read LINE
do
echo $LINE | awk '{print $1}' | read CTD # $CTD = alternative LUN name
CCD="" # $CCD = options (state,type)
# state
echo $LINE | grep "state" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $2}' | awk -F= '{print $2}' | read CCD
fi
# type
echo $LINE | grep "type" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $3}' | awk -F= '{print $2}' | read CCT
CCD=${CCD}","${CCT}
fi
if [ "[$CCD]" == "[]" ]; then
printf "Path%${WkD}d: %-26s\n" $MPC $CTD >> $MPINF
else
printf "Path%${WkD}d: %-26s %s\n" $MPC $CTD $CCD >> $MPINF
fi
MPC=$MPC+1
done
fi
# Determine disk native name c#t#d#
if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
# Determine disk length
prtvtoc -h /dev/dsk/$DNA >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
else
grep "^public:" $DINFO >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
grep "^public:" $DINFO | awk '{print $4}' | awk -F= '{print $NF}' | read DLN
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
else
DLG="?"
fi
fi
echo "${bon}\c"
printf "%-${WiD}s %-26s %d/%d %6s %-8s" $DNM $DNA $NEN $NPT $DLG $DST
echo "${bof}"
if [ "$MULTI" -eq 1 -a -e "$MPINF" ]; then cat $MPINF; fi
done
echo
exit 0
fi
################################################
### General preliminaries on disks/volumes ###
################################################
# Assemble diskgroup list
if [ "$ALLDG" -eq 0 ]; then DGLIST=$*; fi # Diskgroup list as remaining parameters
#################################################
### Summary information for all disk groups ###
#################################################
if [ "$SMINF" -eq 1 ]; then
echo
echo "Summary information for all disk groups"
echo
# We will of course be looking over ALL imported diskgroups
DGLIST=""
grep -v "^DEVICE" $DLIST | awk '{print $4}' | sort -ru | while read DG
do
DGLIST=$DGLIST" "$DG
done
# Determine width of Diskgroup-Name-Column by finding longest diskgroupname
WiG=4
for DG in $DGLIST
do
echo $DG | awk '{print substr($1,1,1) substr($1,length($1),1)}' | read DICHK
if [ "$DICHK" == "()" ]; then
DG=`echo $DG | awk '{print substr($1,2,length($1)-2)}'`
fi
if [ "${#DG}" -gt "$WiG" ]; then WiG=${#DG}; fi
done
WjG=$(($WiG-4))
# Output of dynamic first column of first row
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjG" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "GSt #ds Capa(GB) #sd Used(GB) Free(GB) #vo #pl"
# Output of dynamic first column of second row
integer q=0
while [ "$q" -lt "$WiG" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "--- --- -------- --- -------- -------- --- ---"
# Process active (imported) and inactive (deported) disk groups
for DG in $DGLIST
do
if [ "[$DG]" == "[-]" ]; then continue; fi
integer TDS=0 # Total number of disks in this DG
integer TSD=0 # Total number of subdisks in this DG
integer TCP=0 # Total capacity in this DG in blocks
integer TUC=0 # Total used capacity in this DG in GB
integer TFC=0 # Total free capacity in this DG in GB
echo $DG | awk '{print substr($1,1,1) substr($1,length($1),1)}' | read DICHK
if [ "$DICHK" == "()" ]; then
DG=`echo $DG | awk '{print substr($1,2,length($1)-2)}'`
DGS="dep"
grep $DG $DLIST | awk '{print $1, $6, $7}' | while read DNM DNA DNL
do
# Determine disk length
# a) via Veritas device name $DNM using "vxdisk list"
$VXDISK list $DNM > $DINFO
grep "^public:" $DINFO | awk '{print $4}' | awk -F= '{print $NF}' | read DLN
grep "^hostid:" $DINFO | awk '{print $2}' | read DGAON
### # b) via disk native name $DNA using "prtvtoc"
### if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
### if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
### prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Increase number of disks
TDS=$TDS+1
done
else
DGS="IMP"
# Disk information
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $5}' | while read DLN
do
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Increase number of disks
TDS=$TDS+1
done
# Subdisk information
$VXPRINT -g $DG -s | grep -v "^TY" | awk '{print $5}' | while read SLN
do
# Add subdisk capacity to total capacity
TUC=$TUC+$SLN
# Increase number of subdisks
TSD=$TSD+1
done
# Free space information
$VXDG -g $DG free | grep -v "^DISK" | awk '{print $5}' | while read FLN
do
# Add free chunk capacity to total capacity
TFC=$TFC+$FLN
done
# Volume and Plex information
$VXPRINT -g $DG -v | grep -v "^TY" | wc -l | read NVL
$VXPRINT -g $DG -p | grep -v "^TY" | wc -l | read NPL
TUG=`echo "scale=2; $TUC/2/1024/1024" | bc`
TFG=`echo "scale=2; $TFC/2/1024/1024" | bc`
fi
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
# Print results
if [ "${DGS}" == "IMP" ]; then
echo "${bon}\c"
printf "%-${WiG}s %3s %3d %8s %3d %8s %8s %3s %3d\n" \
$DG ${DGS} $TDS $TCG $TSD $TUG $TFG $NVL $NPL
echo "${bof}\c"
else
if [ "[$DGAON]" == "[]" ]; then DGAON="?"; fi
printf "%-${WiG}s %3s %3d %8s --> %s\n" $DG ${DGS} $TDS $TCG $DGAON
fi
done
# Finally: Unassigned disks
DG="-"
DGS="N/A"
integer TDS=0 # Total number of unassigned disks in this DG
integer TCP=0 # Total capacity of unassigned disks in blocks
awk '$4=="-" {print $1, $5, $6, $7}' $DLIST | while read DNM DST DNA DNL
do
# Determine disk length via disk native name $DNA using "prtvtoc"
if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
prtvtoc -h /dev/dsk/$DNA >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
else
DLN=0
fi
TCP=$TCP+$DLN
TDS=$TDS+1
done
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
printf "%-${WiG}s %3s %3d %8s unassigned\n" $DG ${DGS} $TDS $TCG
echo
exit 0
fi
################################################
### Special preliminaries on disks/volumes ###
################################################
# Any additional information? $AI==0: no; $AI==1,2,3: yes!
AI=$(($MULTI+$FRECH+$DSUBD))
# Check if there is at least one (valid or not) diskgroup in diskgroup list
if [ "$DGLIST" == "" ]; then
echo "HINT: Use option -h for extended help on usage of this script"
echo " OR give at least one diskgroup name"
echo " Available VERITAS diskgroups on this server:"
$VXDG list | grep -v "^NAME" | awk '{print $1}' | while read DG
do
echo " $DG"
done
echo " OR use option -G to display information on ALL diskgroups"
echo " OR use option -u to display information on unassigned disks"
echo " OR use option -S to display summary information on all diskgroups"
echo " OR use option -V to display version information for this script"
exit 2
fi
######################################################
### General information on output of this script ###
######################################################
echo
echo "Information on diskgroups ${bon}${DGLIST}${bof}"
if [ "$XINFO" -eq 1 ]; then
echo "Print standard disk media\c"
if [ "$AI" -eq 0 ]; then
echo " information."
else
if [ "$MULTI" -eq 1 ]; then echo " and multipath\c"; fi
if [ "$DSUBD" -eq 1 ]; then echo " and subdisk\c"; fi
if [ "$FRECH" -eq 1 ]; then echo " and free chunk\c"; fi
echo " information."
fi
fi
if [ "$VINFO" -eq 1 ]; then
echo "Print standard volume\c"
if [ "$PLEXI" -eq 1 ]; then
echo " and plex/subdisk information."
else
echo " information."
fi
fi
echo
######################################
### Information on disks/volumes ###
######################################
# Now process each diskgroup in the diskgroup list
for DG in $DGLIST
do
echo "###################################################"
# Does diskgroup $DG exist on this machine? $RC==0: yes; else: no
$VXDG list | grep $DG >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo
echo "Information on diskgroup ${bon}$DG${bof}"
else
echo
echo "WARNING (diskgroup): No diskgroup ${bon}${DG}${bof} is imported on this system. skipping..."
echo
continue
fi
if [ "$XINFO" -eq 1 ]; then
$VXPRINT -g $DG -htqv > $VLIST
$VXDG -g $DG free > $FLIST
# Determine width of Disk-Name-Column by finding longest diskname
WiD=4
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $2}' | while read DNM
do
if [ "${#DNM}" -gt "$WiD" ]; then WiD=${#DNM}; fi
done
WjD=$(($WiD-4))
# Determine width of Assoc-Name-Column by finding longest assocname
WiA=5
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $3}' | while read ANM
do
if [ "${#ANM}" -gt "$WiA" ]; then WiA=${#ANM}; fi
done
WjA=$(($WiA-5))
echo
echo "${ion}Disk-Info${bof}"
# Output of dynamic first column of header
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjD" ]
do
echo " \c"
q=$q+1
done
# Output of dynamic second column of header
echo "ASSOC \c"
integer q=0
while [ "$q" -lt "$WjA" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "Native #P #SD Size Used Free"
# Output of dynamic first column of second (underline) row
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# Output of dynamic second column of second (underline) row
integer q=0
while [ "$q" -lt "$WiA" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "-------------------------- --- --- ------ ------ ------"
integer TDS=0 # Total number of disks in this DG
integer TSD=0 # Total number of subdisks in this DG
integer TCP=0 # Total capacity in this DG in blocks
integer TUC=0 # Total used capacity in this DG in GB
integer TFC=0 # Total free capacity in this DG in GB
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $2, $3, $5}' \
| while read DNM DAS DLN
do
# Convert disksize from blocks $DLN to gigabytes $DLG
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Extract c#t#d-name from $DLIST and store in $DNA
grep -w $DNM $DLIST | awk '{print $6}' | read DNA
if [ "$DNA" == "shared" -o "$DNA" == "nohotuse" ]; then
grep -w $DNM $DLIST | awk '{print $7}' | read DNA
fi
# Determine number of devicepaths
### Due to possible errors encapsulate the VXDISK list command:
$VXDISK list $DNM >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
$VXDISK -g $DG list $DNM > $DINFO
else
$VXDISK list $DAS > $DINFO
fi
NEN=0; NPT=0
grep -n "^numpaths:" $DINFO | awk -F: '{print $1, $NF}' | read LIN NPT
# $NPT is the number of paths - but how many of these are enabled?
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | grep -c "enabled" | read NEN
if [ "[$NEN]" == "[]" ]; then NEN=0; fi
if [ "[$NPT]" == "[]" ]; then NPT=0; fi
# Multipathing information - if desired
if [ "$MULTI" -eq 1 ]; then
if [ -w $MPINF ]; then rm $MPINF; fi
integer MPC=1 # Counter for number of (multi)paths
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | while read LINE
do
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $MPINF
q=$q+1
done
echo " \c" >> $MPINF
# Output for dynamic second column
printf "P%3d:" $MPC >> $MPINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $MPINF
q=$q+1
done
echo " \c" >> $MPINF
# On with the rest of the output:
echo $LINE | awk '{print $1}' | read CTD # $CTD = alternative LUN name
CCD="" # $CCD = options (state,type)
# state
echo $LINE | grep "state" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $2}' | awk -F= '{print $2}' | read CCD
fi
# type
echo $LINE | grep "type" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $3}' | awk -F= '{print $2}' | read CCT
CCD=${CCD}","${CCT}
fi
if [ "[$CCD]" == "[]" ]; then
printf "%-26s\n" $CTD >> $MPINF
else
printf "%-26s %s\n" $CTD $CCD >> $MPINF
fi
MPC=$MPC+1
done
fi
# Determine subdisk information
integer NSD=0 # Counter for number of subdisks
integer SSS=0 # Summated size of subdisks
if [ -w $SDINF ]; then rm $SDINF; fi
grep "^sd" $VLIST | grep -w $DNM | awk '{print $2, $5, $6}' | while read SNM SOF SLN
do
NSD=$NSD+1
# Detailed subdisk information - if desired
if [ "$DSUBD" -eq 1 ]; then
SLG=`echo "scale=2; $SLN/2/1024/1024" | bc`
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $SDINF
q=$q+1
done
echo " \c" >> $SDINF
# Output for dynamic second column
printf "SD%2d:" $NSD >> $SDINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $SDINF
q=$q+1
done
echo " \c" >> $SDINF
# On with the rest of the output:
printf "%-26s (OS=%11d) %6s ~ %s\n" $SNM $SOF $SLG $SLN >> $SDINF
fi
SSS=$SSS+$SLN # originally SSS=$SSS+SLN (?)
done
TSD=$TSD+$NSD
TUC=$TUC+$SSS
SSG=`echo "scale=2; $SSS/2/1024/1024" | bc`
# Determine number and size of free chunks on this disk
integer NFC=0 # Counter for number of free chunks
integer SFC=0 # Summated size of free chunks
if [ -w $FCINF ]; then rm $FCINF; fi
grep -w $DNM $FLIST | awk '{print $4, $5}' | while read FOF FLN
do
NFC=$NFC+1
# Free chunk information - if desired
if [ "$FRECH" -eq 1 ]; then
FLG=`echo "scale=2; $FLN/2/1024/1024" | bc`
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $FCINF
q=$q+1
done
echo " \c" >> $FCINF
# Output for dynamic second column
printf "FC%2d:" $NFC >> $FCINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $FCINF
q=$q+1
done
echo " \c" >> $FCINF
# On with the rest of the header:
printf " (OS=%11d) %6s ~ %s\n" \
$FOF $FLG $FLN >> $FCINF
fi
SFC=$SFC+$FLN
done
TFC=$TFC+$SFC
SFG=`echo "scale=2; $SFC/2/1024/1024" | bc`
# Print results
echo "${bon}\c"
printf "%-${WiD}s %-${WiA}s %-26s %d/%d %3d %6s %6s %6s" \
$DNM $DAS $DNA $NEN $NPT $NSD $DLG $SSG $SFG
echo "${bof}"
# Print additional information - if desired
if [ "$MULTI" -eq 1 -a -e "$MPINF" ]; then cat $MPINF; fi
if [ "$DSUBD" -eq 1 -a -e "$SDINF" ]; then sort +2 $SDINF; fi
if [ "$FRECH" -eq 1 -a -e "$FCINF" ]; then cat $FCINF; fi
TDS=$TDS+1
done
echo
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
TUG=`echo "scale=2; $TUC/2/1024/1024" | bc`
TFG=`echo "scale=2; $TFC/2/1024/1024" | bc`
# Print summary information
printf "Total number of disks in this DG: %5d\n" $TDS
printf "Total number of subdisks in this DG: %5d\n" $TSD
printf "Used disk capacity in this DG: %8s GB\n" $TUG
printf "Free disk capacity in this DG: %8s GB\n" $TFG
printf "Total disk capacity in this DG: %8s GB\n" $TCG
echo
fi # disk information $XINFO==1
if [ "$VINFO" -eq 1 ]; then
df -k > $MLIST
echo "${ion}Volume-Info${bof}"
echo "Volume / Plex / Subdisk V Size(GB) #Plexes #SD Mounted on"
echo "------------------------------ - -------- ------- --- --------------------------"
$VXPRINT -g $DG -v | grep -v "^TY" | awk '{print $2, $5}' \
| while read VNM VLN
do
# Convert volsize from blocks $VLN to gigabytes $VLG
VLG=`echo "scale=2; $VLN/2/1024/1024" | bc`
# Determine Mountpoint of Volume $VNM
grep $VNM $MLIST >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
grep $VNM $MLIST | awk '{print $NF}' | read MNT
else
MNT="-"
fi
# Determine number of plexes and subdisks
$VXPRINT -g $DG -htqv $VNM > $VLIS2
grep -c "^sd" $VLIS2 | read VNS # Count subdisks
grep -c "^sv" $VLIS2 | read VNV # Count subvolumes for layered volumes
if [ -w $PLINF ]; then rm $PLINF; fi
integer NDP=0 # Counter for number of data plexes
integer NLP=0 # Counter for number of log plexes
grep "^pl" $VLIS2 | awk '{print $2, $4, $6, $7}' | while read PLN PLS PLT PLL
do
grep $PLN $VLIS2 | grep -c "^sd" | read NSP
if [ "$PLT" == "LOGONLY" ]; then
NLP=$NLP+1
else
NDP=$NDP+1
PLT="DATA"
fi
printf " %-28s %8s %-7s %3d Layout=%s\n" \
$PLN $PLS $PLT $NSP $PLL >> $PLINF
# Further subdisk information - if desired
grep $PLN $VLIS2 | grep "^sd" | awk '{print $2, $6}' | while read SXX SSZ
do
SSH=`echo "scale=2; $SSZ/2/1024/1024" | bc`
printf " %-26s %8s\n" $SXX $SSH >> $PLINF
done
# Further subvolume information
grep $PLN $VLIS2 | grep "^sv" | awk '{print $2, $6}' | while read SXX SSZ
do
SSH=`echo "scale=2; $SSZ/2/1024/1024" | bc`
printf " %-26s %8s sv\n" $SXX $SSH >> $PLINF
done
done
# Determine Veritas file system version (5,6,7 or L for layered volumes)
VFV="-"
fstyp -v /dev/vx/rdsk/$DG/$VNM >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
fstyp -v /dev/vx/rdsk/$DG/$VNM | grep "version" | awk '{print $4}' | read VFV
else
VFV="L"
fi
# Print results
echo "${bon}\c"
if [ "$VNV" -eq 0 ]; then
# Normal volume
printf "%-30s %s %8s %dD + %dL %3d %s" \
$VNM $VFV $VLG $NDP $NLP $VNS $MNT
else
# Layered volume; mark with asterisk * accordingly
printf "%-30s %s %8s %dD + %dL *%3d %s" \
$VNM $VFV $VLG $NDP $NLP $VNV $MNT
fi
echo "${bof}"
if [ "$PLEXI" -eq 1 -a -e "$PLINF" ]; then cat $PLINF; fi
done
echo
fi # volume information $VINF==1
done
exit 0
root#
root# cat chk_dginfo
#!/usr/bin/ksh
# Script: chk_dginfo
# Usage: chk_dginfo [-Adfgmpqsv] <diskgroup list>
# chk_dginfo [-Adfgmpqsv] -G
# chk_dginfo [-gmq] -u
# chk_dginfo [-q] -S
# chk_dginfo -h
# chk_dginfo -V
# Exit codes: 0 = Execution without errors
# 1 = No valid diskgroup found on the system
# 2 = No valid diskgroup given as parameter
# ToDo: Option -l for link volume information (which volumes use SDs from this disk?)
# Option -G for complete disk geometry
###############################
### General preliminaries ###
###############################
# Home location of all used Veritas commands
VXDG=/usr/sbin/vxdg
VXPRINT=/usr/sbin/vxprint
VXDISK=/usr/sbin/vxdisk
# Before we begin: Is VERITAS Volume Manager available on this system at all?
$VXDG list >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
echo "WARNING (availability): VERITAS Volume Manager not available on this system!"
echo "exiting..."
exit 1
fi
# By default NO fancy graphics options
bon="" # `tput bold` = bold characters on
ion="" # `tput smso` = inverse characters on
bof="" # `tput rmso` = output back to normal (bold/inverse off)
# Temporary output files (in /tmp; will disappear after next reboot)
DLIST=/tmp/vxdisk_e_o_alldgs_list
DINFO=/tmp/vxdisk_list_dev
VLIST=/tmp/vxprint_dg_htqv
VLIS2=/tmp/vxprint_dg_htqv_vol
FLIST=/tmp/vxdg_dg_free
MLIST=/tmp/df_k.out
MPINF=/tmp/mpinf.out
SDINF=/tmp/sdinf.out
FCINF=/tmp/fcinf.out
PLINF=/tmp/plinf.out
# Process options
XINFO=1 # Disk info - 0: no; 1: yes (DINFO already reserved)
VINFO=1 # Volume info - 0: no; 1: yes
DSUBD=0 # Detailed subdisk info - 0: no; 1: yes
FRECH=0 # Free chunk info - 0: no; 1: yes
MULTI=0 # Multipath info - 0: no; 1: yes
PLEXI=0 # Plex and subdisk info - 0: no; 1: yes
UNASD=0 # Unassigned disks info - 0: no; 1: yes
ALLDG=0 # 0: use diskgroup list; 1: show info for ALL diskgroups
QUICK=0 # quick-run-option - 0: create new DLIST; 1: use old DLIST (if exists)
SMINF=0 # Summary information - 0: no; 1: yes
################################
### Process script options ###
################################
while getopts "AdfgGhlmpqsSuvV" OPT
do
case $OPT in
A) MULTI=1; DSUBD=1; FRECH=1; PLEXI=1
;;
d) VINFO=0 # No volume info since "disk info only"
;;
f) FRECH=1
;;
g) bon=`tput bold` # bold characters on
ion=`tput smso` # inverse characters on
bof=`tput rmso` # output back to normal (bold/inverse off)
;;
G) ALLDG=1
DGLIST=""
$VXDG list | grep -v "^NAME" | awk '{print $1}' | while read DG
do
DGLIST=$DGLIST" "$DG
done
;;
h) echo "usage: chk_dginfo [-Adfgmpqsv] <diskgroup list>"
echo " chk_dginfo [-Adfgmpqsv] -G"
echo " chk_dginfo [-gmq] -u"
echo " chk_dginfo [-q] -S"
echo " chk_dginfo -h"
echo " chk_dginfo -V"
echo
echo "function: display information on Veritas volume/disks in (blank separated) <diskgroup list>"
echo " or display information on Veritas volume/disks for ALL diskgroups on this system (-G)"
echo " or display information on unassigned Veritas disks (-u)"
echo " or display this help text (-h) and exit"
echo
echo " The information will be displayed in two separate sections:"
echo " 1) The disk info section - 2) The volume info section"
echo
echo "options: I - General options"
echo " -g: enable fancy graphics (feel free to try it out!)"
echo " -G: display information for ALL diskgroups imported on this system"
echo " -h: display this help text and exit"
echo " -q: quick-run-option: use old DLIST file (if exists)"
echo " -V: display version information and exit"
echo
echo " II - Disk info section options"
echo " -d: display disk info section only (skip volume information)"
echo " -f: display free chunk information"
echo " -m: display multipath information"
echo " -s: display detailed subdisk information"
echo
echo " III - Volume info section options"
echo " -p: display detailed volume (plexes and subdisks) information"
echo " -v: display volume info section only (skip disk information)"
echo
echo " IV - Special options"
echo " -A: display ALL information; equivalent to -fmps (both sections)"
echo " -u: display information on unassigned disks (neither section)"
echo " -S: display summary information for all disk groups (neither section)"
echo
echo "legend: NAME: Veritas disk name"
echo " ASSOC: Associated disk name"
echo " Native: Native (c#t#d#) disk name"
echo " #P: Number of enabled / total number of - paths to disk"
echo " #SD: Number of subdisks on this disk"
echo " Size: Capacity of disk in GigaBytes"
echo " Used: Used space on this disk in GigaBytes"
echo " Free: Free space on this disk in GigaBytes"
exit 0
;;
m) MULTI=1 # display multipath information
;;
p) PLEXI=1 # display detailed volume (plexes and subdisks) information
;;
q) QUICK=1 # quick-run-option
;;
s) DSUBD=1 # display detailed subdisk information
;;
S) SMINF=1 # display summary information for all diskgroups
;;
u) UNASD=1 # display information on unassigned disks
;;
v) XINFO=0 # No disk info since "volume info only"
;;
V) echo "Version=1.0 Date=2012/07/10 Opts=\"AdfgGhlmpqsSuvV\""
exit 0
;;
*) echo "This option is not supported and will be ignored."
;;
esac
done
shift `expr $OPTIND - 1`
# Create new or re-use old $DLIST file needed for ALL operations below
if [ "$QUICK" -eq 0 ]; then
$VXDISK -e -o alldgs list > $DLIST
else # [ "$QUICK" -eq 1 ]
ls $DLIST >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
echo "WARNING (quick-run): $DLIST does not exist; create new one"
$VXDISK -e -o alldgs list > $DLIST
fi
fi
#########################################
### Information on unassigned disks ###
#########################################
# If information on unassigned disks was requested, we're done quickly...
if [ "$UNASD" -eq 1 ]; then
echo
echo "Information on ${bon}unassigned${bof} disks"
# Determine width of Disk-Name-Column by finding longest diskname
WiD=4
awk '$4=="-" {print $1}' $DLIST | while read DNM
do
if [ "${#DNM}" -gt "$WiD" ]; then WiD=${#DNM}; fi
done
WjD=$(($WiD-4))
WkD=$(($WiD-5))
echo
# Output of dynamic first column of first row
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjD" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "Native #P Size State"
# Output of dynamic first column of second row
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "-------------------------- --- ------ --------"
awk '$4=="-" {print $1, $5, $6, $7}' $DLIST | while read DNM DST DNA DNL
do
# Determine number of devicepaths
$VXDISK list $DNM > $DINFO
grep -n "^numpaths:" $DINFO | awk -F: '{print $1, $NF}' | read LIN NPT
# $NPT is the number of paths - but how many of these are enabled?
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | grep -c "enabled" | read NEN
# Multipathing information - if desired
if [ "$MULTI" -eq 1 ]; then
if [ -w $MPINF ]; then rm $MPINF; fi
integer MPC=1 # Counter for number of (multi)paths
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | while read LINE
do
echo $LINE | awk '{print $1}' | read CTD # $CTD = alternative LUN name
CCD="" # $CCD = options (state,type)
# state
echo $LINE | grep "state" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $2}' | awk -F= '{print $2}' | read CCD
fi
# type
echo $LINE | grep "type" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $3}' | awk -F= '{print $2}' | read CCT
CCD=${CCD}","${CCT}
fi
if [ "[$CCD]" == "[]" ]; then
printf "Path%${WkD}d: %-26s\n" $MPC $CTD >> $MPINF
else
printf "Path%${WkD}d: %-26s %s\n" $MPC $CTD $CCD >> $MPINF
fi
MPC=$MPC+1
done
fi
# Determine disk native name c#t#d#
if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
# Determine disk length
prtvtoc -h /dev/dsk/$DNA >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
else
grep "^public:" $DINFO >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
grep "^public:" $DINFO | awk '{print $4}' | awk -F= '{print $NF}' | read DLN
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
else
DLG="?"
fi
fi
echo "${bon}\c"
printf "%-${WiD}s %-26s %d/%d %6s %-8s" $DNM $DNA $NEN $NPT $DLG $DST
echo "${bof}"
if [ "$MULTI" -eq 1 -a -e "$MPINF" ]; then cat $MPINF; fi
done
echo
exit 0
fi
################################################
### General preliminaries on disks/volumes ###
################################################
# Assemble diskgroup list
if [ "$ALLDG" -eq 0 ]; then DGLIST=$*; fi # Diskgroup list as remaining parameters
#################################################
### Summary information for all disk groups ###
#################################################
if [ "$SMINF" -eq 1 ]; then
echo
echo "Summary information for all disk groups"
echo
# We will of course be looking over ALL imported diskgroups
DGLIST=""
grep -v "^DEVICE" $DLIST | awk '{print $4}' | sort -ru | while read DG
do
DGLIST=$DGLIST" "$DG
done
# Determine width of Diskgroup-Name-Column by finding longest diskgroupname
WiG=4
for DG in $DGLIST
do
echo $DG | awk '{print substr($1,1,1) substr($1,length($1),1)}' | read DICHK
if [ "$DICHK" == "()" ]; then
DG=`echo $DG | awk '{print substr($1,2,length($1)-2)}'`
fi
if [ "${#DG}" -gt "$WiG" ]; then WiG=${#DG}; fi
done
WjG=$(($WiG-4))
# Output of dynamic first column of first row
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjG" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "GSt #ds Capa(GB) #sd Used(GB) Free(GB) #vo #pl"
# Output of dynamic first column of second row
integer q=0
while [ "$q" -lt "$WiG" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "--- --- -------- --- -------- -------- --- ---"
# Process active (imported) and inactive (deported) disk groups
for DG in $DGLIST
do
if [ "[$DG]" == "[-]" ]; then continue; fi
integer TDS=0 # Total number of disks in this DG
integer TSD=0 # Total number of subdisks in this DG
integer TCP=0 # Total capacity in this DG in blocks
integer TUC=0 # Total used capacity in this DG in GB
integer TFC=0 # Total free capacity in this DG in GB
echo $DG | awk '{print substr($1,1,1) substr($1,length($1),1)}' | read DICHK
if [ "$DICHK" == "()" ]; then
DG=`echo $DG | awk '{print substr($1,2,length($1)-2)}'`
DGS="dep"
grep $DG $DLIST | awk '{print $1, $6, $7}' | while read DNM DNA DNL
do
# Determine disk length
# a) via Veritas device name $DNM using "vxdisk list"
$VXDISK list $DNM > $DINFO
grep "^public:" $DINFO | awk '{print $4}' | awk -F= '{print $NF}' | read DLN
grep "^hostid:" $DINFO | awk '{print $2}' | read DGAON
### # b) via disk native name $DNA using "prtvtoc"
### if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
### if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
### prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Increase number of disks
TDS=$TDS+1
done
else
DGS="IMP"
# Disk information
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $5}' | while read DLN
do
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Increase number of disks
TDS=$TDS+1
done
# Subdisk information
$VXPRINT -g $DG -s | grep -v "^TY" | awk '{print $5}' | while read SLN
do
# Add subdisk capacity to total capacity
TUC=$TUC+$SLN
# Increase number of subdisks
TSD=$TSD+1
done
# Free space information
$VXDG -g $DG free | grep -v "^DISK" | awk '{print $5}' | while read FLN
do
# Add free chunk capacity to total capacity
TFC=$TFC+$FLN
done
# Volume and Plex information
$VXPRINT -g $DG -v | grep -v "^TY" | wc -l | read NVL
$VXPRINT -g $DG -p | grep -v "^TY" | wc -l | read NPL
TUG=`echo "scale=2; $TUC/2/1024/1024" | bc`
TFG=`echo "scale=2; $TFC/2/1024/1024" | bc`
fi
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
# Print results
if [ "${DGS}" == "IMP" ]; then
echo "${bon}\c"
printf "%-${WiG}s %3s %3d %8s %3d %8s %8s %3s %3d\n" \
$DG ${DGS} $TDS $TCG $TSD $TUG $TFG $NVL $NPL
echo "${bof}\c"
else
if [ "[$DGAON]" == "[]" ]; then DGAON="?"; fi
printf "%-${WiG}s %3s %3d %8s --> %s\n" $DG ${DGS} $TDS $TCG $DGAON
fi
done
# Finally: Unassigned disks
DG="-"
DGS="N/A"
integer TDS=0 # Total number of unassigned disks in this DG
integer TCP=0 # Total capacity of unassigned disks in blocks
awk '$4=="-" {print $1, $5, $6, $7}' $DLIST | while read DNM DST DNA DNL
do
# Determine disk length via disk native name $DNA using "prtvtoc"
if [ "$DNA" == "invalid" ]; then DNA=$DNL; fi
if [ "$DNA" == "udid_mismatch" ]; then DNA=$DNL; fi
prtvtoc -h /dev/dsk/$DNA >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
prtvtoc -h /dev/dsk/$DNA | awk '$1=="2" {print $5}' | read DLN
else
DLN=0
fi
TCP=$TCP+$DLN
TDS=$TDS+1
done
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
printf "%-${WiG}s %3s %3d %8s unassigned\n" $DG ${DGS} $TDS $TCG
echo
exit 0
fi
################################################
### Special preliminaries on disks/volumes ###
################################################
# Any additional information? $AI==0: no; $AI==1,2,3: yes!
AI=$(($MULTI+$FRECH+$DSUBD))
# Check if there is at least one (valid or not) diskgroup in diskgroup list
if [ "$DGLIST" == "" ]; then
echo "HINT: Use option -h for extended help on usage of this script"
echo " OR give at least one diskgroup name"
echo " Available VERITAS diskgroups on this server:"
$VXDG list | grep -v "^NAME" | awk '{print $1}' | while read DG
do
echo " $DG"
done
echo " OR use option -G to display information on ALL diskgroups"
echo " OR use option -u to display information on unassigned disks"
echo " OR use option -S to display summary information on all diskgroups"
echo " OR use option -V to display version information for this script"
exit 2
fi
######################################################
### General information on output of this script ###
######################################################
echo
echo "Information on diskgroups ${bon}${DGLIST}${bof}"
if [ "$XINFO" -eq 1 ]; then
echo "Print standard disk media\c"
if [ "$AI" -eq 0 ]; then
echo " information."
else
if [ "$MULTI" -eq 1 ]; then echo " and multipath\c"; fi
if [ "$DSUBD" -eq 1 ]; then echo " and subdisk\c"; fi
if [ "$FRECH" -eq 1 ]; then echo " and free chunk\c"; fi
echo " information."
fi
fi
if [ "$VINFO" -eq 1 ]; then
echo "Print standard volume\c"
if [ "$PLEXI" -eq 1 ]; then
echo " and plex/subdisk information."
else
echo " information."
fi
fi
echo
######################################
### Information on disks/volumes ###
######################################
# Now process each diskgroup in the diskgroup list
for DG in $DGLIST
do
echo "###################################################"
# Does diskgroup $DG exist on this machine? $RC==0: yes; else: no
$VXDG list | grep $DG >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo
echo "Information on diskgroup ${bon}$DG${bof}"
else
echo
echo "WARNING (diskgroup): No diskgroup ${bon}${DG}${bof} is imported on this system. skipping..."
echo
continue
fi
if [ "$XINFO" -eq 1 ]; then
$VXPRINT -g $DG -htqv > $VLIST
$VXDG -g $DG free > $FLIST
# Determine width of Disk-Name-Column by finding longest diskname
WiD=4
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $2}' | while read DNM
do
if [ "${#DNM}" -gt "$WiD" ]; then WiD=${#DNM}; fi
done
WjD=$(($WiD-4))
# Determine width of Assoc-Name-Column by finding longest assocname
WiA=5
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $3}' | while read ANM
do
if [ "${#ANM}" -gt "$WiA" ]; then WiA=${#ANM}; fi
done
WjA=$(($WiA-5))
echo
echo "${ion}Disk-Info${bof}"
# Output of dynamic first column of header
echo "NAME \c"
integer q=0
while [ "$q" -lt "$WjD" ]
do
echo " \c"
q=$q+1
done
# Output of dynamic second column of header
echo "ASSOC \c"
integer q=0
while [ "$q" -lt "$WjA" ]
do
echo " \c"
q=$q+1
done
# On with the rest of the header:
echo "Native #P #SD Size Used Free"
# Output of dynamic first column of second (underline) row
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# Output of dynamic second column of second (underline) row
integer q=0
while [ "$q" -lt "$WiA" ]
do
echo "-\c"
q=$q+1
done
echo " \c"
# On with the rest of the header:
echo "-------------------------- --- --- ------ ------ ------"
integer TDS=0 # Total number of disks in this DG
integer TSD=0 # Total number of subdisks in this DG
integer TCP=0 # Total capacity in this DG in blocks
integer TUC=0 # Total used capacity in this DG in GB
integer TFC=0 # Total free capacity in this DG in GB
$VXPRINT -g $DG -d | grep -v "^TY" | awk '{print $2, $3, $5}' \
| while read DNM DAS DLN
do
# Convert disksize from blocks $DLN to gigabytes $DLG
DLG=`echo "scale=2; $DLN/2/1024/1024" | bc`
# Add disk capacity to total capacity
TCP=$TCP+$DLN
# Extract c#t#d-name from $DLIST and store in $DNA
grep -w $DNM $DLIST | awk '{print $6}' | read DNA
if [ "$DNA" == "shared" -o "$DNA" == "nohotuse" ]; then
grep -w $DNM $DLIST | awk '{print $7}' | read DNA
fi
# Determine number of devicepaths
### Due to possible errors encapsulate the VXDISK list command:
$VXDISK list $DNM >/dev/null 2>&1; RC=$?
if [ "$RC" -ne 0 ]; then
$VXDISK -g $DG list $DNM > $DINFO
else
$VXDISK list $DAS > $DINFO
fi
NEN=0; NPT=0
grep -n "^numpaths:" $DINFO | awk -F: '{print $1, $NF}' | read LIN NPT
# $NPT is the number of paths - but how many of these are enabled?
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | grep -c "enabled" | read NEN
if [ "[$NEN]" == "[]" ]; then NEN=0; fi
if [ "[$NPT]" == "[]" ]; then NPT=0; fi
# Multipathing information - if desired
if [ "$MULTI" -eq 1 ]; then
if [ -w $MPINF ]; then rm $MPINF; fi
integer MPC=1 # Counter for number of (multi)paths
LIN2=$(($LIN+1))
sed -ne "${LIN2},\$p" $DINFO | while read LINE
do
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $MPINF
q=$q+1
done
echo " \c" >> $MPINF
# Output for dynamic second column
printf "P%3d:" $MPC >> $MPINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $MPINF
q=$q+1
done
echo " \c" >> $MPINF
# On with the rest of the output:
echo $LINE | awk '{print $1}' | read CTD # $CTD = alternative LUN name
CCD="" # $CCD = options (state,type)
# state
echo $LINE | grep "state" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $2}' | awk -F= '{print $2}' | read CCD
fi
# type
echo $LINE | grep "type" >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
echo $LINE | awk '{print $3}' | awk -F= '{print $2}' | read CCT
CCD=${CCD}","${CCT}
fi
if [ "[$CCD]" == "[]" ]; then
printf "%-26s\n" $CTD >> $MPINF
else
printf "%-26s %s\n" $CTD $CCD >> $MPINF
fi
MPC=$MPC+1
done
fi
# Determine subdisk information
integer NSD=0 # Counter for number of subdisks
integer SSS=0 # Summated size of subdisks
if [ -w $SDINF ]; then rm $SDINF; fi
grep "^sd" $VLIST | grep -w $DNM | awk '{print $2, $5, $6}' | while read SNM SOF SLN
do
NSD=$NSD+1
# Detailed subdisk information - if desired
if [ "$DSUBD" -eq 1 ]; then
SLG=`echo "scale=2; $SLN/2/1024/1024" | bc`
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $SDINF
q=$q+1
done
echo " \c" >> $SDINF
# Output for dynamic second column
printf "SD%2d:" $NSD >> $SDINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $SDINF
q=$q+1
done
echo " \c" >> $SDINF
# On with the rest of the output:
printf "%-26s (OS=%11d) %6s ~ %s\n" $SNM $SOF $SLG $SLN >> $SDINF
fi
SSS=$SSS+$SLN # originally SSS=$SSS+SLN (?)
done
TSD=$TSD+$NSD
TUC=$TUC+$SSS
SSG=`echo "scale=2; $SSS/2/1024/1024" | bc`
# Determine number and size of free chunks on this disk
integer NFC=0 # Counter for number of free chunks
integer SFC=0 # Summated size of free chunks
if [ -w $FCINF ]; then rm $FCINF; fi
grep -w $DNM $FLIST | awk '{print $4, $5}' | while read FOF FLN
do
NFC=$NFC+1
# Free chunk information - if desired
if [ "$FRECH" -eq 1 ]; then
FLG=`echo "scale=2; $FLN/2/1024/1024" | bc`
# Output for dynamic first column
integer q=0
while [ "$q" -lt "$WiD" ]
do
echo " \c" >> $FCINF
q=$q+1
done
echo " \c" >> $FCINF
# Output for dynamic second column
printf "FC%2d:" $NFC >> $FCINF
integer q=5
while [ "$q" -lt "$WiA" ]
do
echo " \c" >> $FCINF
q=$q+1
done
echo " \c" >> $FCINF
# On with the rest of the header:
printf " (OS=%11d) %6s ~ %s\n" \
$FOF $FLG $FLN >> $FCINF
fi
SFC=$SFC+$FLN
done
TFC=$TFC+$SFC
SFG=`echo "scale=2; $SFC/2/1024/1024" | bc`
# Print results
echo "${bon}\c"
printf "%-${WiD}s %-${WiA}s %-26s %d/%d %3d %6s %6s %6s" \
$DNM $DAS $DNA $NEN $NPT $NSD $DLG $SSG $SFG
echo "${bof}"
# Print additional information - if desired
if [ "$MULTI" -eq 1 -a -e "$MPINF" ]; then cat $MPINF; fi
if [ "$DSUBD" -eq 1 -a -e "$SDINF" ]; then sort +2 $SDINF; fi
if [ "$FRECH" -eq 1 -a -e "$FCINF" ]; then cat $FCINF; fi
TDS=$TDS+1
done
echo
TCG=`echo "scale=2; $TCP/2/1024/1024" | bc`
TUG=`echo "scale=2; $TUC/2/1024/1024" | bc`
TFG=`echo "scale=2; $TFC/2/1024/1024" | bc`
# Print summary information
printf "Total number of disks in this DG: %5d\n" $TDS
printf "Total number of subdisks in this DG: %5d\n" $TSD
printf "Used disk capacity in this DG: %8s GB\n" $TUG
printf "Free disk capacity in this DG: %8s GB\n" $TFG
printf "Total disk capacity in this DG: %8s GB\n" $TCG
echo
fi # disk information $XINFO==1
if [ "$VINFO" -eq 1 ]; then
df -k > $MLIST
echo "${ion}Volume-Info${bof}"
echo "Volume / Plex / Subdisk V Size(GB) #Plexes #SD Mounted on"
echo "------------------------------ - -------- ------- --- --------------------------"
$VXPRINT -g $DG -v | grep -v "^TY" | awk '{print $2, $5}' \
| while read VNM VLN
do
# Convert volsize from blocks $VLN to gigabytes $VLG
VLG=`echo "scale=2; $VLN/2/1024/1024" | bc`
# Determine Mountpoint of Volume $VNM
grep $VNM $MLIST >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
grep $VNM $MLIST | awk '{print $NF}' | read MNT
else
MNT="-"
fi
# Determine number of plexes and subdisks
$VXPRINT -g $DG -htqv $VNM > $VLIS2
grep -c "^sd" $VLIS2 | read VNS # Count subdisks
grep -c "^sv" $VLIS2 | read VNV # Count subvolumes for layered volumes
if [ -w $PLINF ]; then rm $PLINF; fi
integer NDP=0 # Counter for number of data plexes
integer NLP=0 # Counter for number of log plexes
grep "^pl" $VLIS2 | awk '{print $2, $4, $6, $7}' | while read PLN PLS PLT PLL
do
grep $PLN $VLIS2 | grep -c "^sd" | read NSP
if [ "$PLT" == "LOGONLY" ]; then
NLP=$NLP+1
else
NDP=$NDP+1
PLT="DATA"
fi
printf " %-28s %8s %-7s %3d Layout=%s\n" \
$PLN $PLS $PLT $NSP $PLL >> $PLINF
# Further subdisk information - if desired
grep $PLN $VLIS2 | grep "^sd" | awk '{print $2, $6}' | while read SXX SSZ
do
SSH=`echo "scale=2; $SSZ/2/1024/1024" | bc`
printf " %-26s %8s\n" $SXX $SSH >> $PLINF
done
# Further subvolume information
grep $PLN $VLIS2 | grep "^sv" | awk '{print $2, $6}' | while read SXX SSZ
do
SSH=`echo "scale=2; $SSZ/2/1024/1024" | bc`
printf " %-26s %8s sv\n" $SXX $SSH >> $PLINF
done
done
# Determine Veritas file system version (5,6,7 or L for layered volumes)
VFV="-"
fstyp -v /dev/vx/rdsk/$DG/$VNM >/dev/null 2>&1; RC=$?
if [ "$RC" -eq 0 ]; then
fstyp -v /dev/vx/rdsk/$DG/$VNM | grep "version" | awk '{print $4}' | read VFV
else
VFV="L"
fi
# Print results
echo "${bon}\c"
if [ "$VNV" -eq 0 ]; then
# Normal volume
printf "%-30s %s %8s %dD + %dL %3d %s" \
$VNM $VFV $VLG $NDP $NLP $VNS $MNT
else
# Layered volume; mark with asterisk * accordingly
printf "%-30s %s %8s %dD + %dL *%3d %s" \
$VNM $VFV $VLG $NDP $NLP $VNV $MNT
fi
echo "${bof}"
if [ "$PLEXI" -eq 1 -a -e "$PLINF" ]; then cat $PLINF; fi
done
echo
fi # volume information $VINF==1
done
exit 0
root#
No comments:
Post a Comment