I wrote a tiny script that can report the number of stale partitions across multiple Volume Groups. If invoked with the -a flag the script will list LPs, PPs and Stale partitions for all Logical Volumes in all active Volume Groups. Using the -v flag only information for the specified Volume Group will be displayed.
Usage:
stale.sh -v rootvg stale.sh -a
Sample output:
VG: rootvg LV: hd5 LPs: 1 PPs: 2 STALE 0 VG: rootvg LV: hd4 LPs: 6 PPs: 12 STALE 0 VG: rootvg LV: hd2 LPs: 29 PPs: 58 STALE 0 VG: rootvg LV: hd3 LPs: 4 PPs: 8 STALE 0 VG: rootvg LV: hd1 LPs: 2 PPs: 4 STALE 0
The script is here:
#!/bin/ksh # # OS: AIX # stale.sh # Created by: aixdoc.wordpress.com # THERE IS NO WARRANTY FOR THIS SCTIPT ############################################################################################ # This script if invoked with the -a flag will print for all Logical Volumes in all active # # Volume Groups the number of LPs, PPs and stale partitions for each Logical Volume. # # Using the flag -v [ VG Name ] only information for the specified Volume Group will be # # displayed. # ############################################################################################ # Sample output: # # ... # # VG: rootvg LV: hd6 LPs: 16 PPs: 32 STALE 0 # # VG: rootvg LV: hd8 LPs: 1 PPs: 2 STALE 0 # # VG: rootvg LV: hd5 LPs: 1 PPs: 2 STALE 0 # # VG: rootvg LV: hd4 LPs: 6 PPs: 12 STALE 0 # # VG: rootvg LV: hd2 LPs: 29 PPs: 58 STALE 0 # # ... # ############################################################################################ # Check if we run on AIX if [[ `uname -s` != AIX ]] then print 'This script is designed for AIX only' exit 1 fi # Check if tmp file exists, if yes delete the file. if [[ -a /tmp/lslv_stale.out ]] then rm /tmp/lslv_stale.out fi # If no command line argument is specified, print usage if [[ $# -eq 0 ]]; then print 'Usage: stale.sh [-a] List all LVs in all open VGs [-v VG_Name] List LVs in the specified VG' exit fi # If the -a flag is specified, get the list of all LVs from all active VGs. while [[ $1 = -* ]]; do case $1 in -a ) for vg in `lsvg -o` do lsvg -l $vg | awk 'NR>2 { print $1 }' >> /tmp/lslv_stale.out done # Now run lslv against each Logical Volume and format the output as required. for list_lv in `cat /tmp/lslv_stale.out` do lslv $list_lv | awk -vORS=' ' 'NR==1 { printf "%-20s %-40s", "VG: " $6, "LV: " $3 } NR==7 { printf "%-15s %-15s", "LPs: " $2, "PPs: " $4} NR==8 { printf "%-5s %-5s\n", $1, $3 }' done;; # Using the -v flag report only information for the specified VG -v ) lsvg -l $2 | awk 'NR>2 { print $1 }' >> /tmp/lslv_stale.out for list_lv in `cat /tmp/lslv_stale.out` do lslv $list_lv | awk -vORS=' ' 'NR==1 { printf "%-20s %-40s", "VG: " $6, "LV: " $3 } NR==7 { printf "%-15s %-15s", "LPs: " $2, "PPs: " $4} NR==8 { printf "%-5s %-5s\n", $1, $3 }' done;; *) print 'Usage: stale.sh [-a] List all LVs in all open VGs [-v VG_Name] List LVs in the specified VG' return 1 esac shift done # Delete temporary file rm /tmp/lslv_stale.out