Skip to content

mirroring progress in aix

If you wonder why AIX does not really have any tools to report on the progress of mirroring you are mistaken. Every time you execute the lsvg command against a volume group is returns (among others) the number of the Stale partitions. You could also execute the lsvg -M and count the number of the stale partitions. Both of these options, executed at an interval will deliver the decreasing numbers of stale partitions which could be used to generate the progress….

What you have here, are a few lines of code that provide the answer – nothing fancy.

### W.M. Duszyk, 3/2/12
### show percentage of mirrored PPs in a volume group

[[ $# < 1 ]] && { print "Usage: $0 vg_name"; exit 1; } vg=$1 Stale=`lsvg $vg | grep 'STALE PPs:' | awk '{print $6}'` [[ $Stale = 0 ]] && { print "$vg is fully mirrored."; exit 2; } Total=`lsvg $vg | grep 'TOTAL PPs:' | awk '{print $6}'` PercDone=$(( 100 - $(( $(( Stale * 50.0 )) / $Total )) )) echo "Volume group $vg is mirrored $PercDone%." If you decide to use this code (copy/paste), remember that each line above is really a single line of characters!!! Your browser may distort this fact. Have a good weekend! UPDATE: This script will work if the mirrorvg -S but not if the syncvg command was used to create the mirrors - the second command "locks" the volume groups being "synced" while the first one does not.

Posted in Real life AIX, scripts.

Tagged with , , , .

5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Ramon says

    A different version:

    ### W.M. Duszyk, 3/2/12
    ### show percentage of mirrored PPs in volume group

    [[ $# < 1 ]] &vg=$1

    # Changed to evade LVM locks
    # Stale=`lsvg $vg | grep 'STALE PPs:' | awk '{print $6}'`

    Stale=$(lsvg -L $vg | awk '/STALE PPs:/ {print $6}')
    [[ $Stale = 0 ]] &# Changed to evade LVM locks

    # Total=`lsvg $vg | grep 'TOTAL PPs:' | awk '{print $6}'`

    Total=$(lsvg -L $vg | awk '/TOTAL PPs:/ {print $6}')

    PercDone=$(( 100 – $(( $(( Stale * 100.0 )) / $(( Total / 2.0 )) )) ))

    echo "Volume group $vg is mirrored $PercDone%."

  2. Mark says

    I got to remember to use awk and its print function instead of using grep and awk ……
    By the way, I think this will not work. I see you are trying to see if there are STALE partitions, but you need to get their number too.
    Thx 🙂

  3. Sebastian says

    @Ramon: good idea using lscg -L to go get the data even when the vg is locked

  4. Darek Wapinski says

    Hello Waldek,

    Seems to me that when mirrorvg was ran earlier you have to run script with: lsvg -L -l $vg_name due to the fact, that checked VGs was locked by mirrovg command.

    Nice idea. Thanks.

  5. MarkD:-) says

    It all depends how the mirroring state was achieved – see the end of this post for explanation.


Some HTML is OK

or, reply to this post via trackback.

WordPress Anti Spam by WP-SpamShield

Copyright © 2016 - 2017 Waldemar Mark Duszyk. All Rights Reserved. Created by Blog Copyright.