在haproxy的global里添加
stats socket /var/run/haproxy.sock mode 666 level user
打开haproxy的socket监控
以下为监控的脚本
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
#!/bin/bash
[ $1 =
'http_server'
] && WEBGROUP=$1,FRONTEND || WEBGROUP=$1,BACKEND
case
"$2"
in
"comp"
)
IN=`
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $52}'
`
OUT=`
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $53}'
`
echo
"scale=4;($IN-$OUT)/$IN*100"
|
bc
;;
"qcur"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $3}'
;;
"qmax"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $4}'
;;
"scur"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $5}'
;;
"smax"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $6}'
;;
"slim"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $7}'
;;
"stot"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $8}'
;;
"bin"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $9}'
;;
"bout"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $10}'
;;
"dreq"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $11}'
;;
"dresp"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $12}'
;;
"ereq"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $13}'
;;
"econ"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $14}'
;;
"eresp"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $15}'
;;
"eretr"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $16}'
;;
"eredis"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $17}'
;;
"status"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $18}'
;;
"weight"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $19}'
;;
"act"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $20}'
;;
"bck"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $21}'
;;
"chkfail"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $22}'
;;
"chkdown"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $23}'
;;
"lastchg"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $24}'
;;
"downtime"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $24}'
;;
"qlimit"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $26}'
;;
"pid"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $27}'
;;
"iid"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $28}'
;;
"sid"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $29}'
;;
"throttle"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $30}'
;;
"lbtot"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $31}'
;;
"tracked"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $32}'
;;
"tpye"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $33}'
;;
"rate"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $34}'
;;
"rate_lim"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $35}'
;;
"rate_max"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $36}'
;;
"check_status"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $37}'
;;
"check_code"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $38}'
;;
"check_duration"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $39}'
;;
"hrsp_1xx"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $40}'
;;
"hrsp_2xx"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $41}'
;;
"hrsp_3xx"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $42}'
;;
"hrsp_4xx"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $43}'
;;
"hrsp_5xx"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $44}'
;;
"hrsp_other"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $45}'
;;
"hanafail"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $46}'
;;
"req_rate"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $47}'
;;
"req_rate_max"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $48}'
;;
"req_tot"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $49}'
;;
"cli_abrt"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $50}'
;;
"srv_abrt"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $51}'
;;
"comp_in"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $52}'
;;
"comp_out"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $53}'
;;
"comp_byp"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $54}'
;;
"comp_rsp"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $55}'
;;
"lastsess"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $56}'
;;
"last_chk"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $57}'
;;
"last_agt"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $58}'
;;
"qtime"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $59}'
;;
"ctime"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $60}'
;;
"rtime"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $61}'
;;
"ttime"
)
/bin/echo
"show stat"
|
/usr/sbin/socat
/var/run/haproxy
.sock stdio|
awk
-
v
n=$WEBGROUP -F,
'$0~n{print $62}'
;;
*)
/bin/echo
'error'
;;
esac
|
haproxy的一些指标
pxname 组名
svname 服务器名
qcur 当前队列
qmax 最大队列
scur当前会话用户
smax最大会话用户
slim会话限制
stot会话总量
bin入口流量
bout出口流量
dreq拒绝的请求
dresp拒绝的响应
ereq错误请求
econ错误链接
eresp错误响应
wretr警告重试次数
wredis
status服务器状态
weight权重
act是否活动Y/N
bck备用
chkfail检查宕机0
chkdown检查宕机0
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_bypbypass大小
comp_rsp
lastsess
last_chk
last_agt
qtime
ctime
rtime
ttime
本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1713806