On Fri, 1 Sep 2017 19:07:58 +0200, Willy Tarreau <[email protected]> wrote:

> On Fri, Sep 01, 2017 at 05:49:38PM +0200, Lukas Tribus wrote:
> > Hello,
> > 
> > 
> > Am 01.09.2017 um 15:46 schrieb Mariusz Gronczewski:  
> > > Hi,
> > >
> > > I've been working on a piece of code to announce IPs (via ExaBGP) only if:
> > >
> > > * HAProxy is running
> > > * HAProxy actually uses a given IP
> > > * a frontend with given IP is up for few seconds.
> > >
> > > I could do that via lsof but that's pretty processor-intensive.   
> > 
> > Not sure about the stats or admin socket, but why not use ss instead?
> > 
> > Something like:
> > sudo ss -tln  '( sport = :80 or sport = :443 )'
> > 
> > add "-p" if you need the PID.
> > 
> > Should perform well enough.  
> 
> I think it would not be too hard to add this feature to the CLI. We already
> have "show cli socket" which lists the listening stats sockets. We could
> reuse this code to list all listening sockets and not the just stats ones.
> Maybe "show listeners [optional frontend]" or something like this ?
> 
> Just my two cents,
> Willy

Anyway, if anyone's interested I have a version that just uses ss to get open 
sockets and iproute2 to verify "right" IP actually exists on server:

https://github.com/efigence/go-ha2bgp

It generates exabgp3-compatible announcements + few basic protections (delay 
annoucement to allow service to get up, do not immediately withdraw to allow 
for restarts, withdraw if it is flapping for too long). In theory it should be 
compatible with any service that listens on standard tcp socket (filter by 
default only looks for 80 or 443 ports)

We use it for ECMP setup with 4 boxes, upgraded from "just put some ip addr add 
inside haproxy init script and hope nobody ever stops it" setup


--
Mariusz Gronczewski, Administrator

Efigence S. A.
ul. Wołoska 9a, 02-583 Warszawa
T: [+48] 22 380 13 13
F: [+48] 22 380 13 14
E: [email protected] <mailto:[email protected]>

Reply via email to