Need help in scripting to check if rootvg is mirrored or not

Hi

Can some one help me with a script which when executed will check and tell if all the LV's in rootvg are mirrored or not. Say for example in the below server we could see that everything is mirrored except dumplv2. So if I execute the script it should tell that all are mirrored except dumplv2.

Please assist with the script.

BMUT8# lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot            1       2       2    closed/syncd  N/A
hd6                 paging         4       8       2    open/syncd    N/A
fslv37              jfs2            18      36      2    open/syncd    /usr/sap/DAA
paging01            paging      160     320     2    open/syncd    N/A
hd8                 jfs2log         1       2       2    open/syncd    N/A
hd4                 jfs2             2       4       2    open/syncd    /
hd2                 jfs2             27      54      2    open/syncd    /usr
hd9var              jfs2            3       6       2    open/syncd    /var
hd3                 jfs2            11      22      2    open/syncd    /tmp
hd1                 jfs2             1       2       2    open/syncd    /home
hd10opt             jfs2           3       6       2    open/syncd    /opt
fslv01              jfs2             1       2       2    open/syncd    /var/log
fslv02              jfs2             1       2       2    open/syncd    /usr/local
fslv03              jfs2             3       6       2    open/syncd    /opt/patrol
lg_dumplv           sysdump    9       9       1    open/syncd    N/A
hd11admin           jfs2          1       2       2    open/syncd    /admin
fslv04              jfs2             7       14      2    open/syncd    /opt/oscdtws1
dumplv2             sysdump    9       9       1    open/syncd    N/A

Of course. Just post what you have tried and we will correct it until it works.

bakunin

snip:

#!/usr/bin/ksh
TMP_FILE=/tmp/mirror_check.out
if (( $(lspv| grep -cw rootvg) > 1 )); then
        lsvg -l rootvg | awk 'NR > 2 && $2 !~ /^sysdump$/ { if ($3 == $4) {print $0} }' >> $TMP_FILE
        NON_MIRR=`wc -l < $TMP_FILE`
        if (( $NON_MIRR != 0 )); then
                echo "unmirrored LVs found:"
                echo
                cat $TMP_FILE
        fi
fi

The original code was written by zaxxon.
Thank Him not me :wink:

Non mirrored LV whose $2 is "sysdump" are not displayed, this is normal (the script as been coded to behave this way)

long ago it was ok to not mirror sysdump/hd6 BUT AIX will dump to mirrorred device - so that even on a reboot on a single copy after a dump, the dump is there.
i.e. better practice to mirror imho

Moderator comments were removed during original forum migration.
5 Likes

Xray didn't know it - will send him a PM to be a tad more sensible next time. But you are absolutely right Bakunin. That's the way to go.

Excuse me Bakunin,

i saw your post first time after submitting my.
I will hold myself back next time :slight_smile: