Read more

get haproxy stats/informations via socat

Claus-Theodor Riegg
November 10, 2015Software engineer at makandra GmbH

You can configure a stat socket for haproxy in the global section of the configuration file:

global
  daemon
  maxconn 999
  user foobar
  stats socket /var/run/haproxy.stat  # this is the line you want to configure
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

You need socat to query data from this socket.

After installing socat and reconfiguring haproxy you can use this socket to query data from it:

  • show informations like haproxy version, PID, current connections, session rates, tasks, etc..

    echo "show info" | socat unix-connect:/var/run/haproxy.stat stdio
    
  • prints the stats about all frontents and backends (connection statistics etc) in a csv format

    echo "show stat" | socat unix-connect:/var/run/haproxy.stat stdio
    
  • indeed the following prints informations about errors if there are any

    echo "show errors" | socat unix-connect:/var/run/haproxy.stat stdio
    
  • show open sessions with the used backend/frontend, the source, etc..

    echo "show sess" | socat unix-connect:/var/run/haproxy.stat stdio
    
Posted by Claus-Theodor Riegg to makandra dev (2015-11-10 16:05)