Online Expert Day - HPE Data Storage - Live Now
April 24/25 - Online Expert Day - HPE Data Storage - Live Now
Read more
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`"

:)
Dennis Handly
Acclaimed Contributor

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