If test array element multiplication

Ya, I know, who in this day and age is mirroring rootvg...?
But yes, my shop does and I need to script checking for it.

I also know I could just inverse the the logic and call the LV mirrored
if the LPs and PPs were not equal. But I want to do the math in the if test
and also know I could use single element variables but array loading and usage is a learning experience for me.

Here is my script, but doing the math inside the if test is eluding me.

for LV in hd1 hd2 hd3 hd4 hd5
do
set -A LP_PP `lsvg -l rootvg |grep "$LV " |awk '{ print $3" "$4 }'`
if [[ ${LP_PP[0]} == ${LP_PP[1]} ]]       # [0] *2 = [1]
 then
  MRD=mirrored
 else
  MRD="NOT mirrored"
fi
print "$LV is $MRD"
done

Try:

if ((LP_PP[0]*2==LP_PP[1]))
then
   ...

Do you also check for the boot device being on both/all disks in rootvg and the dump device? I had a suggestion that the dump device should not be mirrored, so we created two separate devices, on for each PV. Fortunately, we never needed them, but you never know......

You should probably also check that the LV copies are synchronised. I've no longer got an AIX server so I can't test things, but something simple like lsvg -l | grep -i stale might suffice.

I hope that this helps,
Robin

Chubler_XL interesting, I was sure that was one method I had tried, your tip does get it done, thank you

rbatte1 yes, creating / assigning the second dump device on the 2nd disk, making sure it is bosbooted and setting the bootlist are all in scope for the script. I will also script the proper sizing of both dump devices. The script will also back ground the syncvg cmd. Since some of my rootvg's are rather large it will take some time for them to sync and I will not hang my script processing waiting on that. The script will also have a current status option, thanks.

1 Like

Good to know that these are already in hand/planned. If rootvg is large, what do you do with a mksysb image? You can trim this down, of course, but it's messy and needs maintenance.

Personally I'd always keep rootvg clear apart from the OS, your backup software and enough to recover the filesystems, even if that leaves lots of unused space. Are you short of disk space for other volume groups to put your application data in?

Robin

Other methods are possible but not easier:

if [[ $(( ${LP_PP[0]} * 2 )) == ${LP_PP[1]} ]]

Within $(( )) one often does not need a further ${ } ,
and when you know you have numbers you can compare them with -eq

if [[ $(( LP_PP[0] * 2 )) -eq ${LP_PP[1]} ]]