메뉴 닫기

haproxy 모니터링

# cfg에 모니터링 설정

vi haproxy.conf


root@xx-xxx-xx:/var/lib/neutron/lbaas/v2/2ead0e18-ff12-4b09-af51-b35bb57da220# vi haproxy.conf 
global
..
..
    stats socket /var/lib/neutron/lbaas/v2/2ead0e18-ff12-4b09-af51-b35bb57da220/haproxy_stats.sock mode 0666 level user
..
# stats socket에 정의한다.

1. socat 을 통한 모니터링

socat 설치


root@xx-xxx-xx:~# apt install socat
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다:
  libtomcrypt0 libtommath0 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-53 linux-headers-4.4.0-53-generic linux-image-4.4.0-21-generic linux-image-4.4.0-53-generic
  linux-image-extra-4.4.0-21-generic linux-image-extra-4.4.0-53-generic timelimit
Use 'apt autoremove' to remove them.
다음 새 패키지를 설치할 것입니다:
  socat
0개 업그레이드, 1개 새로 설치, 0개 제거 및 10개 업그레이드 안 함.
321 k바이트 아카이브를 받아야 합니다.
이 작업 후 941 k바이트의 디스크 공간을 더 사용하게 됩니다.

실행 가능 명령어


  clear counters : clear max statistics counters (add 'all' for all counters)
  clear table    : remove an entry from a table
  help           : this message
  prompt         : toggle interactive mode with prompt
  quit           : disconnect
  show backend   : list backends in the current running config
  show info      : report information about the running process
  show pools     : report information about the memory pools usage
  show stat      : report counters for each proxy and server
  show errors    : report last request and response errors for each proxy
  show sess [id] : report the list of current sessions or dump this session
  show table [id]: report table usage stats or dump this table's contents
  show servers state [id]: dump volatile server information (for backend )
  get weight     : report a server's current weight
  set weight     : change a server's weight
  set server     : change a server's state, weight or address
  set table [id] : update or create a table entry's data
  set timeout    : change a timeout setting
  set maxconn    : change a maxconn setting
  set rate-limit : change a rate limiting value
  disable        : put a server or frontend in maintenance mode
  enable         : re-enable a server or frontend which is in maintenance mode
  shutdown       : kill a session or a frontend (eg:to release listening ports)
  show acl [id]  : report avalaible acls or dump an acl's contents
  get acl        : reports the patterns matching a sample for an ACL
  add acl        : add acl entry
  del acl        : delete acl entry
  clear acl  : clear the content of this acl
  show map [id]  : report avalaible maps or dump a map's contents
  get map        : reports the keys and values matching a sample for a map
  set map        : modify map entry
  add map        : add map entry
  del map        : delete map entry
  clear map  : clear the content of this map
  set ssl  : set statement for ssl

예제


root@xx-xxx-xx:/var/lib/neutron/lbaas/v2/2ead0e18-ff12-4b09-af51-b35bb57da220# echo "show info" | socat unix-connect:haproxy_stats.sock stdio
Name: HAProxy
Version: 1.6.3
Release_date: 2015/12/25
Nbproc: 1
Process_num: 1
Pid: 9302
Uptime: 0d 0h27m19s
Uptime_sec: 1639
Memmax_MB: 0
Ulimit-n: 30035
Maxsock: 30035
Maxconn: 15000
Hard_maxconn: 15000
CurrConns: 0
CumConns: 448
CumReq: 451
MaxSslConns: 0
CurrSslConns: 0
CumSslConns: 0
Maxpipes: 0
PipesUsed: 0
PipesFree: 0
ConnRate: 0
ConnRateLimit: 0
MaxConnRate: 4
SessRate: 0
SessRateLimit: 0
MaxSessRate: 4
SslRate: 0
SslRateLimit: 0
MaxSslRate: 0
SslFrontendKeyRate: 0
SslFrontendMaxKeyRate: 0
SslFrontendSessionReuse_pct: 0
SslBackendKeyRate: 0
SslBackendMaxKeyRate: 0
SslCacheLookups: 0
SslCacheMisses: 0
CompressBpsIn: 0
CompressBpsOut: 0
CompressBpsRateLim: 0
ZlibMemUsage: 0
MaxZlibMemUsage: 0
Tasks: 9
Run_queue: 1
Idle_pct: 100
node: xx-xxx-xx
description: 

root@xx-xxx-xx:/var/lib/neutron/lbaas/v2/2ead0e18-ff12-4b09-af51-b35bb57da220# echo "show stat" | socat unix-connect: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,
0.0.0.0,FRONTEND,,,0,4,15000,6,1791,59296,0,0,2,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,2,,,,0,3,0,3,0,0,,0,2,6,,,0,0,0,0,,,,,,,,
0.0.0.0,BACKEND,0,0,0,0,1500,0,1791,59296,0,0,,0,0,0,0,UP,0,0,0,,0,1106,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,469,,,0,0,0,11,
d13f86a7-a7ed-48d2-9d9b-a853bee77334,FRONTEND,,,0,5,15000,270,26701,73628,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,4,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
a81b6099-a11d-4216-a50c-a3004eef53dd,fc0752ce-7867-465e-b398-497bdf9d9c0d,0,0,0,2,,96,13534,27572,,0,,0,0,0,0,UP,1,1,0,0,0,1106,0,,1,4,1,,96,,2,0,,1,L4OK,,0,,,,,,,0,,,,0,0,,,,,348,,,0,0,0,22,
a81b6099-a11d-4216-a50c-a3004eef53dd,9cd2b8f4-68d4-42e7-9dcd-6553f2286d88,0,0,0,3,,78,5852,20976,,0,,0,0,0,0,UP,1,1,0,1,1,922,183,,1,4,2,,78,,2,0,,1,L4OK,,0,,,,,,,0,,,,0,0,,,,,347,,,0,0,0,43,
a81b6099-a11d-4216-a50c-a3004eef53dd,1ca7f9bf-8d57-4aba-9d8b-a1860bcb2d35,0,0,0,2,,96,7315,25080,,0,,0,0,0,0,UP,1,1,0,0,0,1106,0,,1,4,3,,96,,2,0,,2,L4OK,,0,,,,,,,0,,,,0,0,,,,,346,,,0,0,0,19,
a81b6099-a11d-4216-a50c-a3004eef53dd,BACKEND,0,0,0,5,1500,270,26701,73628,0,0,,0,0,0,0,UP,3,3,0,,0,1106,0,,1,4,0,,270,,1,0,,4,,,,,,,,,,,,,,0,0,0,0,0,0,346,,,0,0,0,69,

2. nc 을 통한 모니터링

예제


root@xx-xxx-xx:/var/lib/neutron/lbaas/v2/a861c1e5-b10c-4138-840e-2d3035b3694c# echo "show info;show stat" | nc -U haproxy_stats.sock
Name: HAProxy
Version: 1.6.3
Release_date: 2015/12/25
Nbproc: 1
Process_num: 1
Pid: 21624
Uptime: 0d 0h23m15s
Uptime_sec: 1395
Memmax_MB: 0
Ulimit-n: 30035
Maxsock: 30035
Maxconn: 15000
Hard_maxconn: 15000
CurrConns: 0
CumConns: 155
CumReq: 165
MaxSslConns: 0
CurrSslConns: 0
CumSslConns: 0
Maxpipes: 0
PipesUsed: 0
PipesFree: 0
ConnRate: 0
ConnRateLimit: 0
MaxConnRate: 3
SessRate: 0
SessRateLimit: 0
MaxSessRate: 3
SslRate: 0
SslRateLimit: 0
MaxSslRate: 0
SslFrontendKeyRate: 0
SslFrontendMaxKeyRate: 0
SslFrontendSessionReuse_pct: 0
SslBackendKeyRate: 0
SslBackendMaxKeyRate: 0
SslCacheLookups: 0
SslCacheMisses: 0
CompressBpsIn: 0
CompressBpsOut: 0
CompressBpsRateLim: 0
ZlibMemUsage: 0
MaxZlibMemUsage: 0
Tasks: 9
Run_queue: 1
Idle_pct: 100
node: xx-xxx-xx
description: 

# 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,
0.0.0.0,FRONTEND,,,0,4,15000,13,4350,192695,0,0,3,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,3,,,,0,10,0,3,0,0,,0,3,13,,,0,0,0,0,,,,,,,,
0.0.0.0,BACKEND,0,0,0,0,1500,0,4350,192695,0,0,,0,0,0,0,UP,0,0,0,,0,1395,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,567,,,0,0,0,5,
e064d206-47b0-468c-8270-ad6bd16e3037,FRONTEND,,,0,1,15000,1,216,280,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,1,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,d8bb386e-9882-4f70-8eb8-a63058977ffa,0,0,0,1,,1,216,280,,0,,0,0,0,0,UP,1,1,0,0,0,1395,0,,1,4,1,,1,,2,0,,1,L4OK,,0,,,,,,,0,,,,0,0,,,,,61,,,0,0,0,1,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,7aa9c739-3910-4ca5-8750-aad0df0ded33,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,1395,0,,1,4,2,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,197839a7-1234-4b0e-8cb3-076c42c90f6e,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,1395,0,,1,4,3,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,BACKEND,0,0,0,1,1500,1,216,280,0,0,,0,0,0,0,UP,3,3,0,,0,1395,0,,1,4,0,,1,,1,0,,1,,,,,,,,,,,,,,0,0,0,0,0,0,61,,,0,0,0,1,

root@xx-xxx-xx:/var/lib/neutron/lbaas/v2/a861c1e5-b10c-4138-840e-2d3035b3694c# echo "show sess;show stat" | nc -U haproxy_stats.sock
Permission denied

# 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,
0.0.0.0,FRONTEND,,,0,4,15000,13,4350,192695,0,0,3,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,3,,,,0,10,0,3,0,0,,0,3,13,,,0,0,0,0,,,,,,,,
0.0.0.0,BACKEND,0,0,0,0,1500,0,4350,192695,0,0,,0,0,0,0,UP,0,0,0,,0,1403,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,575,,,0,0,0,5,
e064d206-47b0-468c-8270-ad6bd16e3037,FRONTEND,,,0,1,15000,1,216,280,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,1,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,d8bb386e-9882-4f70-8eb8-a63058977ffa,0,0,0,1,,1,216,280,,0,,0,0,0,0,UP,1,1,0,0,0,1403,0,,1,4,1,,1,,2,0,,1,L4OK,,0,,,,,,,0,,,,0,0,,,,,69,,,0,0,0,1,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,7aa9c739-3910-4ca5-8750-aad0df0ded33,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,1403,0,,1,4,2,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,197839a7-1234-4b0e-8cb3-076c42c90f6e,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,1403,0,,1,4,3,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
5fb96fb8-5726-4f81-9ede-3b305a37e8f1,BACKEND,0,0,0,1,1500,1,216,280,0,0,,0,0,0,0,UP,3,3,0,,0,1403,0,,1,4,0,,1,,1,0,,1,,,,,,,,,,,,,,0,0,0,0,0,0,69,,,0,0,0,1,

3. hatop 을 통한 모니터링

hatop 설치


root@xx-xxx-xx:~# apt install hatop
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다:
  libtomcrypt0 libtommath0 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-headers-4.4.0-53 linux-headers-4.4.0-53-generic linux-image-4.4.0-21-generic linux-image-4.4.0-53-generic
  linux-image-extra-4.4.0-21-generic linux-image-extra-4.4.0-53-generic timelimit
Use 'apt autoremove' to remove them.
다음 새 패키지를 설치할 것입니다:
  hatop
0개 업그레이드, 1개 새로 설치, 0개 제거 및 10개 업그레이드 안 함.
24.7 k바이트 아카이브를 받아야 합니다.
이 작업 후 135 k바이트의 디스크 공간을 더 사용하게 됩니다.

예제


root@xx-xxx-xx:~# hatop -i 1 -s /var/lib/neutron/lbaas/v2/a861c1e5-b10c-4138-840e-2d3035b3694/haproxy_stats.sock 
  HAProxy Version: 1.6.3  (released: 2015/12/25)        PID: 21624 (proc 1)

         Node: xx-xxxx-xx (uptime 0d 0h27m55s)

        Pipes: [                                                       0/0]
  Connections: [                                                   0/15000]

  Procs:   1   Tasks:     9    Queue:     1    Proxies:   3   Services:    7

NAME                                W STATUS           CHECK                       ACT           BCK            QCUR            QMAX             SCUR             SMAX             SLIM             STOT

>>> 0.0.0.0                                                                                                                                                                                             
FRONTEND                            0 OPEN                                           0             0               0               0                0                4            15000               13
BACKEND                             0 UP                                             0             0               0               0                0                0             1500                0

>>> e064d206-47b0-468c-8270-ad6bd16e3037
FRONTEND                            0 OPEN                                           0             0               0               0                0                1            15000                1

>>> 5fb96fb8-5726-4f81-9ede-3b305a37e8f1
..0-8eb8-a63058977ffa               1 UP               L4OK                          1             0               0               0                0                1                0                1
..5-8750-aad0df0ded33               1 UP               L4OK                          1             0               0               0                0                0                0                0
..e-8cb3-076c42c90f6e               1 UP               L4OK                          1             0               0               0                0                0                0                0
BACKEND                             3 UP                                             3             0               0               0                0                1             1500                1

1-STATUS  2-TRAFFIC  3-HTTP  4-ERRORS  5-CLI
# 1~5 까지 번호 선택하여 확인 가능하다.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x