Haproxy-stats is a small Python library for fetching and parsing realtime stats from HAProxy
pip install haproxy-stats
from haproxystats import HAProxyServer
haproxy = HAProxyServer('127.0.0.1:3212')
for b in haproxy.backends:
print('%s: %s' % (b.name, b.status))
backend1: UP
backend2: UP
backend3: UP
haproxy.to_json()
{
"127.0.0.1": {
"backends": [
{
"status": "UP",
"lastchg": 497805,
"weight": 0,
"..."
"listeners": []
}
],
"frontends": []
}
}
full docs available in the docs/ folder