Today's Posts

BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

If test array element multiplication

shell scripts

Login to Reply

Thread Tools Search this Thread
# 1  
Old 07-16-2018
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
set -A LP_PP `lsvg -l rootvg |grep "$LV " |awk '{ print $3" "$4 }'`
if [[ ${LP_PP[0]} == ${LP_PP[1]} ]]       # [0] *2 = [1]
  MRD="NOT mirrored"
print "$LV is $MRD"

# 2  
Old 07-16-2018

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

# 3  
Old 07-17-2018
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,
# 4  
Old 07-17-2018
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.
The Following User Says Thank You to gtsonoma For This Useful Post:
rbatte1 (07-17-2018)
# 5  
Old 07-17-2018
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?

# 6  
Old 07-17-2018
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]} ]]

Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Array Element cumeh1624 UNIX for Advanced & Expert Users 3 12-13-2014 08:33 AM
Multiplication of array elements rimasbimas Shell Programming and Scripting 4 11-11-2014 08:56 AM
How to insert an array element within regex? Ophiuchus Shell Programming and Scripting 4 09-10-2013 06:24 PM
Not able to call an element from an array in ksh Marc G Shell Programming and Scripting 3 10-26-2012 11:25 AM
Filter output as an array element paslas Shell Programming and Scripting 2 04-27-2012 11:42 AM
Multiplying array element nextyoyoma Shell Programming and Scripting 7 04-16-2012 11:57 AM
How to delete a duplicate element from below array. workforsiva Programming 4 04-06-2012 01:00 AM
Perl XML::DOM: How to test if element exists? Juha UNIX for Advanced & Expert Users 2 11-09-2011 11:52 AM
previous element in the array perl guidely Shell Programming and Scripting 1 09-26-2011 09:00 AM
How to assign an array element to a variable kaushik_87 Shell Programming and Scripting 3 04-26-2011 11:54 AM
remove an element from array michaelrozar17 Shell Programming and Scripting 3 08-31-2010 08:27 AM
HELP unsetting array element in loop msf5042 Shell Programming and Scripting 2 05-10-2010 02:10 AM
Shift array element darshakraut Shell Programming and Scripting 2 05-22-2009 08:32 PM
Perl delete an element from array ahtat99 Shell Programming and Scripting 6 01-18-2007 09:25 AM
accessing my first element of array afadaghi Shell Programming and Scripting 4 09-29-2005 05:43 PM

All times are GMT -4. The time now is 02:22 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
Show Password