티스토리 뷰

haproxy 분배 현황 커맨드로 확인하기기 (haproxy stats command line)




로드밸랜서가 가능한 haproxy 는 분배현황을 직관적으로 확인하기가 약간 힘들다.


lvs 같은 경우는 watch ipvsadm -ln 명령어를 입력하면 아래와 같이 직관적으로 2초마다 확인이 가능하다다


 

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  192.168.0.1:80 sh

  -> 192.168.0.2:80              Masq    1  0          0




haproxy에서 분배 현황을 확인하는 위해 haproxy.cfg 에 설정을 해줘야 한다



listen stats :10004

        stats enable

        stats uri     /

        stats hide-version




공식적으로는 stats 라고 부르는 설정이며 위와 같이 설정하는 경우 아이피와 위에 입력한 포트 


10004번을 같이 입력하면 웹 브라우져에서 확인가능하다.


http://아이피:10004





위와 같이 확인가능하다



커맨드로 확인하고자 한다면



global 옵션쪽에  아래와 같이 한줄 추가해주면 확인 가능하다



 stats socket /tmp/haproxy mode 600 level admin




아래 명령어를 통해 확인 가능한데


echo "show stat" | nc -U /tmp/haproxy


 

# 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,

stats,FRONTEND,,,0,4,10000,17,43972,2014909,0,0,8,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,2,,,,0,113,0,8,0,0,,0,11,121,,,0,0,0,0,,,,,,,,

stats,BACKEND,0,0,0,0,1000,0,43972,2014909,0,0,,0,0,0,0,UP,0,0,0,,0,239016,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,4990,,,0,0,0,128,

가상아이피:80,FRONTEND,,,0,7,10000,1566,745926,9206298,0,0,14,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,51,,,,0,328,472,766,0,0,,0,52,1566,,,0,0,0,0,,,,,,,,

가상아이피:80,분배할아이피:80,0,0,0,5,,777,386564,7760570,,0,,0,0,0,0,UP,1,1,0,0,0,239016,0,,1,3,1,,777,,2,0,,26,L4OK,,0,0,278,440,59,0,0,0,,,,2,0,,,,,19908,,,0,0,9,95,

가상아이피:80,분배할아이피:80,0,0,0,6,,775,359358,1443646,,0,,0,0,0,0,UP,1,1,0,1,1,209365,40,,1,3,2,,775,,2,0,,26,L4OK,,0,0,50,32,693,0,0,0,,,,0,0,,,,,19908,,,0,1,12,47,

가상아이피:80,BACKEND,0,0,0,7,1000,1552,745926,9206298,0,0,,0,0,0,0,UP,2,2,0,,0,239016,0,,1,3,0,,1552,,1,0,,52,,,,0,328,472,752,0,0,,,,,2,0,0,0,0,0,19908,,,0,0,16,111,




pxname, svname ... 부터는 필드의 명이며 그 아래 라인부터 , 쉼표로 구분되어지는 해당 필드의 값들이다.



보기가 힘들므로 내가 원하는 특정값만을 추출할려면 grep 과 awk 를 사용해서 특정값만 출력할수도 있다.



 echo "show stat" | nc -U /tmp/haproxy | grep 가상아이피:80,분배할아이피:80 | awk -F, '{print $5}'




간단하게 HAPROXY 데몬이 실행되어 있는지 확인할려면 ps 명령어로 프로세스를 확인하던가 cat /var/run/haproxy.pid PID 파일이 존재하는지 확인



참고사이트



 http://tech.fawk.eu/111






'LAYER 4 & 7' 카테고리의 다른 글

haproxy health check 에러  (0) 2018.04.10
로드밸랜서 ipvsadm 분배현황 보기  (0) 2015.07.30
squid.conf 옵션 정리  (0) 2015.06.12
Squid result codes  (0) 2015.06.12
squid 기본 개념 정리  (0) 2015.06.12
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함