[root@nim]/root/scripts/bin# cat check_mirror.sh
#!/usr/bin/ksh93 #@(#) Check Mirror compliance # if one LV has miltiple copies, it will check all VG # if it has the same number of copies, except for "test" # v1.1 Manu 09-2016 # Add a file check_mirror.cfg with VG to exclude if needed dir=`dirname $0` . $dir/.env exclude_hosts="test|lab" if [ -e $configfile ] then excludevg=$(cat $configfile | tr '\n' '|' | rev | cut -c2- | rev) else excludevg="None" fi for vg in $(lsvg -o) do nb=$(lsvg $vg | grep STALE | rev | cut -d' ' -f1) if [[ "$nb" != "0" ]] then echo "VG $vg $nb PPs stale" fi done copies=$(lsvg -o | grep -v "caavg_private" | egrep -v "$excludevg" | xargs lsvg -l | awk '{print $2,$3,$4}' | egrep "jfs|boot|paging" | while read i j k do echo "scale=0;$k/$j" | bc done | sort -u | wc -l | awk '{print $1}') if [ "$copies" -gt "1" ] then echo $(hostname) | egrep -q "${exclude_hosts}" if [ "$?" -ne 0 ] then echo "Mirroring error on host $(hostname -s)" if [ "$1" == "-v" ] then for vg in $(lsvg -o | grep -v "caavg_private") do badvg=0 lsvg -l $vg | awk '{print $2,$3,$4}' | egrep "jfs|boot|paging" | while read i j k do copy=$(echo "scale=0;$k/$j" | bc) if [ "$copies" != "$copy" ] then badvg=1 fi done if [ "$badvg" == "1" ] then echo bad VG: $vg fi done fi fi exit 1 else exit 0 fi