Monitoring HAProxy using HATOP


As an administrator, you know that monitoring a service is essential. With HAProxy, there are stats for which you will want to know that aren’t presented to you through TOP or in log files. To make these stats visible, HAProxy can create socket file that can then be accessed by a third-party application to extract the stats. One of the best and most popular is HATOP.

HATop is written in Python. Before you can use it to monitor your load balancer, you should ensure that Python 2 is installed. Most distributions install it by default, even in minimal installations.

Installing HATOP


The package is available from Ubuntu’s default repositories. This makes it a lot easier to install, as compared with other Linux Distributions.

    1. Install HATOP
      sudo apt-get install hatop -y



CentOS \ Debian \ etc

To install HATOP on other Linux distributions, you will need to download the tar file from the project’s website.

  1. Download the latest tar file from the project’s website.
  2. Extract the contents from the downloaded tar file.
    tar xvf hatop-0.7.7.tar.gz
  3. Change into the newly extracted directory.
    cd hatop-0.7.7
  4. Install the HATOP python scripts to /usr/local/bin and set permissions to 755.
    install -m 755 bin/hatop /usr/local/bin
  5. Install the HATOP man files.
    install -m 644 man/hatop.1 /usr/local/share/man/man1
  6. Compress the man files.
    gzip /usr/local/share/man/man1/hatop.1

Create HAPRoxy Socket

To allow HATOP to collect stats from HAProxy, we need to configure HAProxy so that it creates a socket file. This socket file is what HATOP needs to access the different statistics.

  1. Open the HAProxy configuration file in a text editor.
    vi /etc/haproxy/haproxy.cfg
  2. Under the global section of the configuration file, add the stats option as seen in the example below.
    stats socket /var/run/haproxy.sock mode 600 level admin
  3. Restart the HAProxy service to create the new socket.
    sudo service haproxy restart

    As an alternative, you could also reload haproxy instead to minimize downtime in a production environment.

Launching HATop

  1. Run the following command to start HATop
    sudo hatop -s /var/run/haproxy.sock
  2. You should now see HATop’s status screen, as seen in the following screenshot.
    HATOP - Status screen for HAProxy