haproxyのステータス確認
haproxyのステータス確認方法をいつも忘れてしまうのでメモ代わりに書いておきます。
haproxyのsocketをcatするsocat
コマンドを使います。
以下のように書くことで8080番への入力を標準出力に書き込むことができます。 簡単dす。
$ socat tcp-listen:8080 stdout
haproxyではechoを使って取得したいログの種別を指定します。 まずはバージョン情報など基本的な情報を取ってみます。
root@gw01:~# echo "show info" | socat unix-connect:/etc/haproxy/sock stdio Name: HAProxy Version: 1.4.24 Release_date: 2013/06/17 Nbproc: 1 Process_num: 1 Pid: 24498 Uptime: 0d 0h08m59s Uptime_sec: 539 Memmax_MB: 0 Ulimit-n: 4013 Maxsock: 4013 Maxconn: 2000 Maxpipes: 0 CurrConns: 1 PipesUsed: 0 PipesFree: 0 Tasks: 2 Run_queue: 1 node:gw01 description:
コマンド一覧をhelpで取ってみました。
clear counters : clear max statistics counters (add 'all' for all counters) help : this message prompt : toggle interactive mode with prompt quit : disconnect show info : report information about the running process 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 get weight : report a server's current weight set weight : change a server's weight set timeout : change a timeout setting disable server : set a server in maintenance mode enable server : re-enable a server that was previously in maintenance mode
backendのステータスなどはshow stat
で確認可能です。
root@gw01:~# echo "show stat" | socat unix-connect:/etc/haproxy/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, 07625016-88cc-4533-a0b0-cd006b54c110,FRONTEND,,,0,0,2000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,1,0,,,,0,0,0,0,,,,,,,,,,,0,0,0,,, 2c8ff70e-1345-4642-8689-1ce7d74506a8,6f37e25b-713e-4c31-8671-aec5c23a878e,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,1278,0,,1,2,1,,0,,2,0,,0,L4OK,,3,,,,,,,0,,,,0,0, 2c8ff70e-1345-4642-8689-1ce7d74506a8,BACKEND,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,UP,1,1,0,,0,1278,0,,1,2,0,,0,,1,0,,0,,,,,,,,,,,,,,0,0,
こんな感じで必要な情報だけ引っ張ります。svname
とstatus
をピックアップしています。
root@gw01:~# echo "show stat" | socat unix-connect:/etc/haproxy/sock stdio | grep -v -e '^#\|^$' | cut -d ',' -f 2,18 --output-delimiter=':' FRONTEND:OPEN 6f37e25b-713e-4c31-8671-aec5c23a878e:UP BACKEND:UP
- 作者: みやたひろし
- 出版社/メーカー: SBクリエイティブ
- 発売日: 2014/10/05
- メディア: オンデマンド (ペーパーバック)
- この商品を含むブログを見る
- 作者: 編集部
- 出版社/メーカー: 技術評論社
- 発売日: 2015/06/16
- メディア: Kindle版
- この商品を含むブログを見る
- 作者: みやたひろし
- 出版社/メーカー: ソフトバンククリエイティブ
- 発売日: 2012/06/04
- メディア: 大型本
- 購入: 4人 クリック: 204回
- この商品を含むブログ (4件) を見る
シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。
The Tale of Plack - YAPC::Asia Tokyo 2010 YAPC::Asia Tokyo Talk Transcript Series
posted with amazlet at 15.08.29
(2014-09-13)
売り上げランキング: 111,502
売り上げランキング: 111,502