On Fri, 1 Sep 2017 17:49:38 +0200, Lukas Tribus <[email protected]> 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. > Huh, interesting. I just assumed it will be similiar speed no matter which tool I use to get that info but ss does that < 100 ms while lsof and netstat take ages: time lsof -iTCP -sTCP:LISTEN >/dev/null real 0m13.460s user 0m0.201s sys 0m12.897s time netstat -l -n -t >/dev/null real 0m43.439s user 0m0.190s sys 0m42.395s time ss -tln '( sport = :80 or sport = :443 )' >/dev/null real 0m0.032s user 0m0.000s sys 0m0.032s Now I know why netstat is getting replaced instead of "just" fixed... thanks. -- 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]>

