To check the status of the HAProxy service the stats
socket
directive must be defined in the
haproxy.cfg
file:
global # turn on stats unix socket stats socket /var/lib/haproxy/stats ...
HAProxy must be restarted if you change the
haproxy.cfg
file.
To check the status of the HAProxy service using the nc command:
shell> echo "show stat" | sudo nc -U /var/lib/haproxy/stats
You should get a response similar to this example which has a frontend and a backend defined with three cluster nodes:
# 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,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime, connector,FRONTEND,,,0,1,3000,2,1261,4062,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,, connector,conn1,0,0,0,1,5000,1,605,1915,,0,,0,0,0,0,UP,3,1,0,0,0,327,0,,1,3,1,,1,,2,0,,1,L4OK,,0,,,,,,,0,,,,1,0,,,,,306,,,0,0,0,4, connector,conn2,0,0,0,1,5000,1,656,2147,,0,,0,0,0,0,UP,3,1,0,0,0,327,0,,1,3,2,,1,,2,0,,1,L4OK,,0,,,,,,,0,,,,0,1,,,,,302,,,0,0,0,138, connector,conn3,0,0,0,0,5000,0,0,0,,0,,0,0,0,0,UP,3,1,0,0,0,327,0,,1,3,3,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0, connector,BACKEND,0,0,0,1,300,2,1261,4062,0,0,,0,0,0,0,UP,18,6,0,,0,327,0,,1,3,0,,2,,1,0,,1,,,,,,,,,,,,,,1,1,0,0,0,0,302,,,0,0,0,141,
You must have the nc command installed, and the command needs to access the socket as root.