Posted about 3 years ago. Visible to the public.

get haproxy stats/informations via socat

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

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

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..

    Copy
    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

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

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

    Copy
    echo "show sess" | socat unix-connect:/var/run/haproxy.stat stdio

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Claus-Theodor Riegg
Last edit:
about 3 years ago
by Claus-Theodor Riegg
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Claus-Theodor Riegg to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more