我的一个 HAProxy 监控脚本无法在新设置的 HAProxy 框上运行。我已将问题追溯到统计套接字的输出,而不是脚本本身。
我通过套接字报告的值为“0”,但从 Web 界面获得的是正确的值。
有人能解释一下输出的差异吗?
从输出echo 'show stat' | nc -U /var/run/haproxy.socket
:
pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,
haproxystats,FRONTEND,,,0,0,4096,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,1,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,
haproxystats,BACKEND,0,0,0,0,4096,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,155,0,,1,1,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,
vip1,FRONTEND,,,0,0,4096,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,
webservers,web1,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,1,,0,,2,0,,0,L7OK,200,0,0,0,0,0,0,0,0,,,,0,0,
webservers,web2,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,2,,0,,2,0,,0,L7OK,200,0,0,0,0,0,0,0,0,,,,0,0,
webservers,web3,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,3,,0,,2,0,,0,L7OK,200,0,0,0,0,0,0,0,0,,,,0,0,
webservers,web4,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,4,,0,,2,0,,0,L7OK,200,1,0,0,0,0,0,0,0,,,,0,0,
webservers,web5,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,5,,0,,2,0,,0,L7OK,200,0,0,0,0,0,0,0,0,,,,0,0,
webservers,web6,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,155,0,,1,3,6,,0,,2,0,,0,L7OK,200,0,0,0,0,0,0,0,0,,,,0,0,
webservers,BACKEND,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,UP,6,6,0,,0,155,0,,1,3,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,
来自同一服务器的 Web 界面的 CSV 输出:
pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,
haproxystats,FRONTEND,,,1,2,4096,309,186616,3323540,0,0,0,,,,,OPEN,,,,,,,,,1,1,0,,,,0,1,0,4,,,,0,225,0,0,83,0,,1,4,309,,,
haproxystats,BACKEND,0,0,0,1,4096,83,186616,3323540,0,0,,83,0,0,0,UP,0,0,0,,0,231,0,,1,1,0,,0,,1,1,,2,,,,0,0,0,0,83,0,,,,,0,0,
vip1,FRONTEND,,,6,11,4096,20,45181,1069426,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,7,,,,0,69,3,4,0,0,,0,30,76,,,
webservers,web1,0,0,0,2,,13,7445,243262,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,1,,13,,2,0,,5,L7OK,200,1,0,12,1,0,0,0,0,,,,0,0,
webservers,web2,0,0,0,1,,13,7445,127627,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,2,,13,,2,0,,5,L7OK,200,0,0,12,0,1,0,0,0,,,,0,0,
webservers,web3,0,0,0,1,,13,7570,81039,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,3,,13,,2,0,,5,L7OK,200,0,0,13,0,0,0,0,0,,,,0,0,
webservers,web4,0,0,0,1,,13,8053,182209,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,4,,13,,2,0,,5,L7OK,200,1,0,11,1,1,0,0,0,,,,0,0,
webservers,web5,0,0,0,2,,12,7288,230933,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,5,,12,,2,0,,5,L7OK,200,1,0,11,0,1,0,0,0,,,,0,0,
webservers,web6,0,0,0,1,,12,7380,204356,,0,,0,0,0,0,UP,1,1,0,0,0,231,0,,1,3,6,,12,,2,0,,5,L7OK,200,1,0,10,1,1,0,0,0,,,,0,0,
webservers,BACKEND,0,0,0,6,0,76,45181,1069426,0,0,,0,0,0,0,UP,6,6,0,,0,231,0,,1,3,0,,76,,1,0,,30,,,,0,69,3,4,0,0,,,,,0,0,
版本信息:
[root@haproxy ~]# haproxy -v
HA-Proxy version 1.4.19 2012/01/07
相关配置示例:
global
log 127.0.0.1 local0 debug
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/run/haproxy.socket
权限:
[root@haproxy ~]# ls -lah /var/run/haproxy.socket
srwxr-xr-x 1 root root 0 Mar 9 14:13 /var/run/haproxy.socket