HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

mirror details

 
SOLVED
Go to solution
himacs
Super Advisor

mirror details

Hi Admins,

I want to get the mirror status of vg00 on more than 50 servers.So used below script

>>
for i in `bdf|sed 1d|awk '{print $1}'|grep -i '/dev'|grep vg00`
do
B=`lvdisplay $i|grep Mirror|awk '{print $3}'`
if [ $B -ne 0 ]
then
echo " All LVs are mirrored"
else
echo " LV $i is unmirrored"
fi
done
>>

Script providing mirror status fine.But as not am expected.If mirror is 1 then output should be "All LVs are mirrored" else LV $i is unmirrored" . But my scripts provides All LVs are mirrored" n no. of times , where n is total no. of LVs present in vg00.

Please suggest .

Regards/himacs
3 REPLIES
Noé
Valued Contributor
Solution

Re: mirror details

Hi.
I don't undestand very well what you want, but try this and tell me:

for i in `vgdisplay -v vg00 |grep "LV Na" |awk '{print $NF}'`
do
MIRROR=$(lvdisplay $i |awk '/Mirror/ {print $NF}')
if [[ ${MIRROR} -eq 0 ]]
then
echo "$i no esta en Mirror en `hostname`"
fi
done

Regards

Noé.
Noé
Valued Contributor

Re: mirror details


Sorry, the echo must be:
echo "$i is not in Mirror in `hostname`"

:)

Re: mirror details

If you want to check if ALL LVs on vg00 are mirrored, then you need to loop through all of them and then report how many:
typeset -i total=0 mirrored=0
for i in $(bdf | sed 1d | awk '{print $1}' | grep "/dev.*vg00"); do
B=$(lvdisplay $i | grep Mirror | awk '{print $3}')
if [ $B -ne 0 ]; then
(( mirrored += 1 ))
else
echo " LV $i is not mirrored"
fi
(( total += 1 ))
done
if [ $total -eq $mirrored ]; then
echo " All LVs are mirrored"
fi