From 7cfb1ac503c6a505c76acf02ba5ebc97e1e5b053 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Thu, 9 Jun 2016 16:22:10 +0200 Subject: [PATCH] #2 Provide simple script to talk to HaProxy socket --- README.md | 23 +++++++++++++++++++++++ tasks/install.yml | 8 ++++++++ templates/hasocket | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 templates/hasocket diff --git a/README.md b/README.md index 8b231b9..33a10af 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,26 @@ The seqeuence of those compoenents is this: - Private Key, e.g. example.com.key.pem - Domain Certficate, e.g. example.com.crt.pem - Intermediate Certificate, e.g. example.com.ca.crt.pem + +# Watching statistics + +Create an SSH tunnel to the haproxy host's port 7000 and then go to `http://127.0.0.1:7000/haproxy_stats` to get live stats. + +# Talking to HaProxy Socket + +HaProxy can communicate with the console through a socket and we provide a script called `hasocket` which can be used for that purpose. You either call that from the proxy's console or run it through Ansible with this command: + +``` +a -a "hasocket 'help'" --limit=proxyserver +``` + +Useful commands might be: + +- "show info" + show informations like haproxy version, PID, current connections, session rates, tasks, etc.. +- "show stat" + prints the stats about all frontents and backends (connection statistics etc) in a csv format +- "show errors" + indeed the following prints informations about errors if there are any +- "show sess" + show open sessions with the used backend/frontend, the source, etc.. diff --git a/tasks/install.yml b/tasks/install.yml index 54c9031..e6f8ad2 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -44,3 +44,11 @@ owner='root' group='root' mode='644' + +- name: "Proxy | Install script to read socket" + template: + src='hasocket' + dest='/usr/local/bin/hasocket' + owner='root' + group='root' + mode='755' diff --git a/templates/hasocket b/templates/hasocket new file mode 100644 index 0000000..f679d13 --- /dev/null +++ b/templates/hasocket @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "$1" | sudo socat unix-connect:/run/haproxy/admin.sock stdio -- GitLab