[Rdo-list] How to know which galera server haproxy is pointing in an overcloud HA env
Marius Cornea
mcornea at redhat.com
Thu Oct 8 16:27:29 UTC 2015
----- Original Message -----
> From: "Raoul Scarazzini" <rasca at redhat.com>
> To: "Marius Cornea" <mcornea at redhat.com>
> Cc: rdo-list at redhat.com
> Sent: Thursday, October 8, 2015 4:15:59 PM
> Subject: Re: [Rdo-list] How to know which galera server haproxy is pointing in an overcloud HA env
>
> Il giorno 7/10/2015 17:21:11, Marius Cornea ha scritto:
> > I was just suggesting a way to see to which of the backend nodes
> haproxy is directing the traffic. Please see the attachment.
>
> Thanks again Marius,
> from your point of view, does this script make sense?
>
> #!/bin/bash
>
> # haproxy bind address
> VIP=$1
>
> # Associative array for controller -> bytes list
> declare -A controllers
>
> function get_stats {
> # 2nd field -> controller name | 10th field -> bytes in | 11th field ->
> bytes out
> stats=$(echo "show stat" | socat /var/run/haproxy stdio | grep
> mysql,overcloud | cut -f2,10 -d,)
> }
>
> get_stats
>
> # Put the first byte values in the array
> for line in $stats
> do
> controller=$(echo $line | cut -f1 -d,)
> controllers[$controller]=$(echo $line|cut -f2 -d,)
> done
>
> # Do something (nothing) on the VIP's db
> mysql -u nonexistant -h $VIP &> /dev/null
>
> get_stats
>
> # Compare the stats the one different is the master
> for controller in ${!controllers[@]}
> do
> value2=$(echo "$stats"|grep $controller|cut -f2 -d,)
> [ ${controllers[$controller]} -ne $value2 ] && echo "$controller is
> MASTER" || echo "$controller is slave"
> done
>
> I know it's ugly, but since we don't have any other method to get those
> informations I don't see any other solution. Of course it can be adapted
> to get values from http instead of the socket (that by default is not
> enabled).
>
> What do you think?
Looks good to me, I gave it a try on my system and it did the job.
> Thanks a lot,
>
> --
> Raoul Scarazzini
> rasca at redhat.com
>
More information about the dev
mailing list