Browse Source

Scripts to monitor stale PPs with (e.g. when syncing a mirror)

master
Emiel Kollof 7 years ago
parent
commit
4f32ee6e20
  1. 23
      showprogress-perlv.sh
  2. 64
      showprogress-pervg.sh

23
showprogress-perlv.sh

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
#!/bin/bash
#
# Tries to figure out which disks need to be added to which vg on the host
hostname=${1}
if [ ${#} != 1 ]; then
echo "${0} <LPAR>"
exit 255
fi
active=$(ssh ${hostname} lsvg -o)
active_lv=$(ssh ${hostname} lsvg -l ${active} | grep open | awk '{print $1}')
for lv in ${active_lv}; do
total_pp=$(ssh ${hostname} lslv -L ${lv} | grep 'PPs:' | head -1 | awk '{print $4}')
num_stale_pp=$(ssh ${hostname} lslv -L ${lv} | grep 'STALE PP' | awk '{print $3}')
if ((${num_stale_pp} > 0)); then
((stale_pp_count = stale_pp_count + 1))
echo "${hostname} : ${lv} has ${num_stale_pp}/${total_pp} stale PPs"
fi
done

64
showprogress-pervg.sh

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
#!/bin/bash
#
# Shows progress of volume group syncing by looking at stale PPs
#
hostname=${1}
if [ ${#} != 1 ]; then
echo "${0} <LPAR>"
exit 255
fi
mkdir -p timestamps
active=$(ssh ${hostname} lsvg -o)
total=0
for vg in ${active}; do
vgdata=$(ssh ${hostname} lsvg ${vg})
total_pp=$(printf "${vgdata}\n" | grep 'TOTAL PP' | awk '{print $6}')
num_stale_pp=$(printf "${vgdata}\n" | grep 'STALE PP' | awk '{print $6}')
pp_size=$(printf "${vgdata}\n" | grep 'PP SIZE' | awk '{print $6}')
if ((${num_stale_pp} > 0)); then
if [ ! -e timestamps/${hostname}-pervg-${vg}.stamp ]; then
date +%s > timestamps/${hostname}-pervg-${vg}.stamp
fi
if [ ! -e timestamps/${hostname}-pervg-${vg}.numpp ]; then
echo ${num_stale_pp} > timestamps/${hostname}-pervg-${vg}.numpp
fi
now=$(date +%s)
starttime=$(cat timestamps/${hostname}-pervg-${vg}.stamp)
startpps=$(cat timestamps/${hostname}-pervg-${vg}.numpp)
((delta=(now-starttime)+1))
((numprocessed=startpps-num_stale_pp))
((totalprocessed=total_pp-num_stale_pp))
((processed=total_pp*pp_size - totalprocessed*pp_size))
((stampprocessed=(numprocessed*pp_size)))
if ((${delta} > 0)); then
((speed=stampprocessed/delta))
else
speed=0
fi
if ((${speed} > 0)); then
((secleft=processed / speed + 1))
hsecleft=$(printf '%dh:%dm:%ds\n' $(($secleft/3600)) $(($secleft%3600/60)) $(($secleft%60)))
else
hsecleft="INF"
fi
echo "${hostname}: ${vg} : ${processed} MB remaining . ${speed} MB/sec (est). ETA ~${hsecleft}."
((total=total+speed))
else
rm -f timestamp/${hostname}-pervg-${vg}.stamp
rm -f timestamp/${hostname}-pervg-${vg}.numpp
fi
done
if ((${total} > 0)); then
echo "Total throughput: ${total} MB/sec"
echo
fi
Loading…
Cancel
Save