openSUSE Leap 16

HAProxy : 統計情報を参照する (コマンド)2025/11/28

 

HAProxy サーバーの統計情報がコマンドで参照できるように設定します。

[1] 必要なパッケージをインストールしておきます。
dlp:~ #
zypper -n install socat
[2] HAProxy の設定です。
dlp:~ #
vi /etc/haproxy/haproxy.cfg
# 設定確認
# [global] セクション内に以下の設定があれば OK

global
.....
.....
  stats socket /run/haproxy/stats.sock *****

dlp:~ #
systemctl reload haproxy

[3] 以上の設定の後、以下のようにして参照可能です。
# 現在の状態を表示

dlp:~ #
echo "show info" | socat /run/haproxy/stats.sock stdio

Name: HAProxy
Version: 3.2.0
Release_date: 2025/05/28
Nbthread: 2
Nbproc: 1
Process_num: 1
Pid: 2100
Uptime: 0d 0h06m12s
Uptime_sec: 372
Memmax_MB: 0
PoolAlloc_MB: 0
PoolUsed_MB: 0
PoolFailed: 0
Ulimit-n: 65571
Maxsock: 65571
Maxconn: 32768
Hard_maxconn: 32768
CurrConns: 0
CumConns: 376
CumReq: 12
.....
.....

# 統計情報を CSV 形式で出力

dlp:~ #
echo "show stat" | socat /run/haproxy/stats.sock stdio
# 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,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,wrew,connect,reuse,cache_lookups,cache_hits,srv_icur,src_ilim,qtime_max,ctime_max,rtime_max,ttime_max,eint,idle_conn_cur,safe_conn_cur,used_conn_cur,need_conn_est,uweight,agg_server_status,agg_server_check_status,agg_check_status,srid,sess_other,h1sess,h2sess,h3sess,req_other,h1req,h2req,h3req,proto,-,ssl_sess,ssl_reused_sess,ssl_failed_handshake,ssl_ocsp_staple,ssl_failed_ocsp_staple,h2_headers_rcvd,h2_data_rcvd,h2_settings_rcvd,h2_rst_stream_rcvd,h2_goaway_rcvd,h2_detected_conn_protocol_errors,h2_detected_strm_protocol_errors,h2_rst_stream_resp,h2_goaway_resp,h2_open_connections,h2_backend_open_streams,h2_total_connections,h2_backend_total_streams,h1_open_connections,h1_open_streams,h1_total_connections,h1_total_streams,h1_bytes_in,h1_bytes_out,h1_spliced_bytes_in,h1_spliced_bytes_out,
http-in,FRONTEND,,,0,1,10000,1,8336,28273,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,0,2,0,7,0,0,,0,2,9,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,1,1,0,0,0,0,,,0,0,,,,,,,0,,,,,,,,,,0,0,1,0,0,0,9,0,,-,1,0,0,0,0,9,0,3,0,0,0,0,0,0,0,0,1,9,0,0,0,0,0,0,0,0,
http-in,sock-1,,,0,0,0,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,1,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0.0.0:80,,http,,,,0,,0,0,0,,,,,,,,,,,0,,,,,,,,,,,,,,,,,,tcpv4,-,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,
http-in,sock-2,,,0,1,0,1,8336,28273,0,0,0,,,,,OPEN,,,,,,,,,1,2,2,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0.0.0:443,,http,,,,1,,0,0,0,,,,,,,,,,,0,,,,,,,,,,,,,,,,,,tcpv4,-,1,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,
backend_servers,node01,0,0,0,1,,3,2618,3029,,0,,0,0,0,0,UP,1,1,0,0,0,435,0,,1,3,1,,3,,2,0,,1,L4OK,,0,0,1,0,2,0,0,,,,3,0,0,,,,,378,,,0,0,1,7867,,,,Layer4 check passed,,2,3,4,,,,10.0.0.51:80,,http,,,,,,,,0,2,1,,,0,,0,0,1,16351,0,0,0,0,1,1,,,,0,,,,,,,,,,-,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,
backend_servers,node02,0,0,0,1,,3,2558,4045,,0,,0,0,0,0,UP,1,1,0,0,0,435,0,,1,3,2,,3,,2,0,,1,L4OK,,0,0,0,0,3,0,0,,,,3,0,0,,,,,361,,,0,0,1,1227,,,,Layer4 check passed,,2,3,4,,,,10.0.0.52:80,,http,,,,,,,,0,2,1,,,0,,0,0,1,2030,0,0,0,0,1,1,,,,0,,,,,,,,,,-,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,
backend_servers,BACKEND,0,0,0,1,1000,9,8336,28273,0,0,,0,0,0,0,UP,2,2,0,,0,435,0,,1,3,0,,6,,1,0,,2,,,,0,2,0,7,0,0,,,,9,2,0,0,0,0,0,361,,,0,0,1,4783,,,,,,,,,,,,,,http,roundrobin,,,,,,,0,4,2,0,0,,,0,0,1,16351,0,,,,,2,0,0,0,,,,,,,,,,,-,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,6,7727,5454,0,0,

# 現在のセッションを表示

dlp:~ #
echo "show sess" | socat /run/haproxy/stats.sock stdio
0x563dcb3a52a0: proto=unix_stream src=unix:2 fe=GLOBAL be=<NONE> srv=<none> ts=00 epoch=0 age=0s calls=1 rate=0 cpu=0 lat=0 rq[f=848000h,i=0,an=00h,ax=] rp[f=80008000h,i=0,an=00h,ax=] scf=[8,0h,fd=14,rex=10s,wex=] scb=[8,1h,fd=-1,rex=,wex=] exp=10s rc=0 c_exp=
関連コンテンツ