Difference between revisions of "Haproxy"
Jump to navigation
Jump to search
| Line 17: | Line 17: | ||
- https://github.com/bcicen/haproxy-stats | - https://github.com/bcicen/haproxy-stats | ||
| + | ``` | ||
| + | import time | ||
| + | from haproxystats import HAProxyServer | ||
| + | haproxy = HAProxyServer('10.64.4.51:8404/stats') | ||
| + | while True: | ||
| + | json = haproxy.to_json() | ||
| + | time.sleep(5) | ||
| + | print(json) | ||
| + | ``` | ||
| + | |||
| + | ``` | ||
from haproxystats import HAProxyServer | from haproxystats import HAProxyServer | ||
haproxy = HAProxyServer('10.64.4.51:8404/stats') | haproxy = HAProxyServer('10.64.4.51:8404/stats') | ||
| Line 22: | Line 33: | ||
for b in haproxy.backends: | for b in haproxy.backends: | ||
print('%s: %s' % (b.name, b.status)) | print('%s: %s' % (b.name, b.status)) | ||
| + | |||
| + | haproxy.to_json() | ||
| + | ``` | ||
Revision as of 00:08, 23 March 2020
frontend stats
bind *:8404
stats enable
# stats uri /stats
stats uri /stats
stats refresh 10s
mode http
stats auth admin:admin
# stats admin if LOCALHOST
# acl network_allowed src 10.x.x.x 1.1.1.1 2.2.2.2 10.0.0.0/8
# stats admin if network_allowed
- http://10.x.x.x:8404/stats
- http://10.x.x.x:8404/stats?stats;csv;norefresh
- https://github.com/bcicen/haproxy-stats
import time from haproxystats import HAProxyServer haproxy = HAProxyServer('10.64.4.51:8404/stats') while True:
json = haproxy.to_json() time.sleep(5) print(json)
<br />
from haproxystats import HAProxyServer haproxy = HAProxyServer('10.64.4.51:8404/stats')
for b in haproxy.backends:
print('%s: %s' % (b.name, b.status))
haproxy.to_json() ```