差異處
這裏顯示兩個版本的差異處。
tech:zabbix:haproxy [2015/05/25 19:33] – 建立 jonathan | tech:zabbix:haproxy [2015/05/25 19:35] (目前版本) – [@HAProxy Server 安裝程序] jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== HAProxy 納入 Zabbix 監控 ====== | ||
+ | * Prerequisites | ||
+ | * Zabbix Server >= 2.x | ||
+ | * Zabbix Frontend >= 2.x | ||
+ | * HAProxy >= 1.3 | ||
+ | * Socat | ||
+ | |||
+ | ===== @HAProxy Server 安裝程序 ===== | ||
+ | * 新增 userparameter_haproxy.conf <code sh> | ||
+ | vi / | ||
+ | # | ||
+ | # Discovery Rule | ||
+ | # | ||
+ | |||
+ | # HAProxy Frontend, Backend and Server Discovery rules | ||
+ | UserParameter=haproxy.list.discovery[*],/ | ||
+ | |||
+ | |||
+ | # Frontend / Backend current sessions | ||
+ | UserParameter=haproxy.stat.bin[*], | ||
+ | UserParameter=haproxy.stat.bout[*], | ||
+ | UserParameter=haproxy.stat.scur[*], | ||
+ | UserParameter=haproxy.stat.status[*], | ||
+ | </ | ||
+ | * 新增 haproxy_discovery.sh <code sh> | ||
+ | vi / | ||
+ | #!/bin/bash | ||
+ | # | ||
+ | # Get list of Frontends and Backends from HAPROXY | ||
+ | # Example: ./ | ||
+ | # First argument is optional and should be used to set location of your HAPROXY socket | ||
+ | # Second argument is should be either FRONTEND, BACKEND or SERVERS, will default to FRONTEND if not set | ||
+ | # | ||
+ | # !! Make sure the user running this script has Read/Write permissions to that socket !! | ||
+ | # | ||
+ | ## haproxy.cfg snippet | ||
+ | # global | ||
+ | # stats socket / | ||
+ | |||
+ | # | ||
+ | HAPROXY_SOCK="/ | ||
+ | [ -n " | ||
+ | |||
+ | get_stats() { | ||
+ | echo "show stat" | socat ${HAPROXY_SOCK} stdio 2>/ | ||
+ | } | ||
+ | |||
+ | [ -n " | ||
+ | case $1 in | ||
+ | B*) END=" | ||
+ | F*) END=" | ||
+ | S*) | ||
+ | for backend in $(get_stats | grep BACKEND | cut -d, -f1 | uniq); do | ||
+ | for server in $(get_stats | grep " | ||
+ | serverlist=" | ||
+ | done | ||
+ | done | ||
+ | echo ' | ||
+ | exit 0 | ||
+ | ;; | ||
+ | *) END=" | ||
+ | esac | ||
+ | |||
+ | for frontend in $(get_stats | grep " | ||
+ | felist=" | ||
+ | done | ||
+ | echo ' | ||
+ | </ | ||
+ | chmod a+x / | ||
+ | </ | ||
+ | * / | ||
+ | * / | ||
+ | * 重起 zabbix-agent <code sh> | ||
+ | service zabbix-agent restart</ | ||
+ | * 測試< | ||
+ | </ | ||
+ | haproxy.list.discovery[BACKEND] | ||
+ | </ | ||
+ | |||
+ | ===== @Zabbix Server 設定程序 ===== | ||
+ | * 至 https:// | ||
+ | * 將 haproxy_zbx_template.xml 匯入至 Zabbix Server → Configuration → Templates → Import | ||
+ | |||
+ | ===== 參考網址 ===== | ||
+ | * http:// | ||
+ | |||
+ | {{tag> | ||