sensu-plugins-haproxy 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +25 -0
- data/bin/metrics-haproxy.rb +156 -36
- data/lib/sensu-plugins-haproxy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eac4b8bdf306f0728cd979d1cb3ea8e3dfec908
|
4
|
+
data.tar.gz: 0e412f2e7b914a6e4dcb731aad2e893ca4e3835e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ead0552383f5dc301fcb58793a58420aca0ab8e9970f74374e02fe04cb47d75a38500c0bf01527df9d73ff6c101c338d99b12158e99854e7c0e4f04c9e3316e
|
7
|
+
data.tar.gz: 431821d24f2c108fb469e13a2a38e3c638ef9d128b79d534a99141ba8742cf65a90ee1da8b04d3c9250c1a646c16b91aee1dcca5aad4dcc43188175058a6fae5
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.4.0] - 2017-09-09
|
10
|
+
### Added
|
11
|
+
- metrics-haproxy.rb: new flag to expose all possible metrics `--expose-all` (@bergerx)
|
12
|
+
- added flag to use raw haproxy metric names `--use-haproxy-names` (@bergerx)
|
13
|
+
- added flag to include explicit type names in generated metrics names `--use-explicit-names` (@bergerx)
|
14
|
+
|
9
15
|
## [1.3.0] - 2017-08-05
|
10
16
|
### Added
|
11
17
|
- Flag to use SSL in `check-haproxy.rb` (@foozmeat) (@Evesey)
|
@@ -69,7 +75,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
69
75
|
### Added
|
70
76
|
- initial release
|
71
77
|
|
72
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.
|
78
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.4.0...HEAD
|
79
|
+
[1.4.0]:https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.3.0...1.4.0
|
73
80
|
[1.3.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.2.0...1.3.0
|
74
81
|
[1.2.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.1.0...1.2.0
|
75
82
|
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.0.0...1.1.0
|
data/README.md
CHANGED
@@ -14,6 +14,31 @@
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
|
18
|
+
### Metrics
|
19
|
+
|
20
|
+
```
|
21
|
+
$ /opt/sensu/embedded/bin/metrics-haproxy.rb --help
|
22
|
+
Usage: /opt/sensu/embedded/bin/metrics-haproxy.rb (options)
|
23
|
+
-f BACKEND1[,BACKEND2], comma-separated list of backends to fetch stats from. Default is all backends
|
24
|
+
--backends
|
25
|
+
-c HOSTNAME|SOCKETPATH, HAproxy web stats hostname or path to stats socket (required)
|
26
|
+
--connect
|
27
|
+
-a, --expose-all Expose all possible metrics, includes "--server-metrics", "--backends" will still in effect
|
28
|
+
-p, --pass PASSWORD HAproxy web stats password
|
29
|
+
-q, --statspath STATUSPATH HAproxy web stats path (the / will be prepended to the STATUSPATH e.g stats)
|
30
|
+
-P, --port PORT HAproxy web stats port
|
31
|
+
-r, --retries RETRIES Number of times to retry fetching stats from haproxy before giving up.
|
32
|
+
-i, --retry_interval SECONDS Interval (seconds) between retries
|
33
|
+
-s, --scheme SCHEME Metric naming scheme, text to prepend to metric
|
34
|
+
--server-metrics Gathers additional frontend metrics, i.e. total requests
|
35
|
+
--use-explicit-names Use explicit names for frontend, backend, server, listener
|
36
|
+
--use-haproxy-names Use raw names as used in haproxy CSV format definition rather than human friendly names
|
37
|
+
-S, --use-ssl Use SSL to connect to HAproxy web stats
|
38
|
+
-u, --user USERNAME HAproxy web stats username
|
39
|
+
$
|
40
|
+
```
|
41
|
+
|
17
42
|
## Installation
|
18
43
|
|
19
44
|
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
data/bin/metrics-haproxy.rb
CHANGED
@@ -34,6 +34,102 @@ require 'uri'
|
|
34
34
|
# HA Proxy Metrics
|
35
35
|
#
|
36
36
|
class HAProxyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
37
|
+
# Check http://cbonte.github.io/haproxy-dconv/1.7/management.html#9.1 for
|
38
|
+
# haproxy stats CSV format.
|
39
|
+
|
40
|
+
TYPE_FRONTEND = '0'.freeze
|
41
|
+
TYPE_BACKEND = '1'.freeze
|
42
|
+
TYPE_SERVER = '2'.freeze
|
43
|
+
TYPE_LISTENER = '3'.freeze
|
44
|
+
# All fields are listed here for ease of long term maintenance.
|
45
|
+
# Format: field_index => %w(haproxy-name friendly-name)
|
46
|
+
CSV_FIELDS = {
|
47
|
+
0 => %w(pxname proxy_name),
|
48
|
+
1 => %w(svname service_name),
|
49
|
+
2 => %w(qcur queued_requests_current),
|
50
|
+
3 => %w(qmax queued_requests_max),
|
51
|
+
4 => %w(scur session_current),
|
52
|
+
5 => %w(smax session_max),
|
53
|
+
6 => %w(slim session_limit),
|
54
|
+
7 => %w(stot session_total),
|
55
|
+
8 => %w(bin bytes_in),
|
56
|
+
9 => %w(bout bytes_out),
|
57
|
+
10 => %w(dreq request_denied_security),
|
58
|
+
11 => %w(dresp response_denied_security),
|
59
|
+
12 => %w(ereq request_errors),
|
60
|
+
13 => %w(econ connection_errors),
|
61
|
+
14 => %w(eresp response_errors),
|
62
|
+
15 => %w(wretr warning_retries),
|
63
|
+
16 => %w(wredis warning_redispatched),
|
64
|
+
17 => %w(status status),
|
65
|
+
18 => %w(weight weight),
|
66
|
+
19 => %w(act servers_active),
|
67
|
+
20 => %w(bck servers_backup),
|
68
|
+
21 => %w(chkfail healthcheck_failed),
|
69
|
+
22 => %w(chkdown healthcheck_transitions),
|
70
|
+
23 => %w(lastchg healthcheck_seconds_since_change),
|
71
|
+
24 => %w(downtime healthcheck_downtime),
|
72
|
+
25 => %w(qlimit server_queue_limit),
|
73
|
+
26 => %w(pid process_id),
|
74
|
+
27 => %w(iid proxy_id),
|
75
|
+
28 => %w(sid server_id),
|
76
|
+
29 => %w(throttle server_throttle_percent),
|
77
|
+
30 => %w(lbtot server_selected),
|
78
|
+
31 => %w(tracked tracked_server_id),
|
79
|
+
32 => %w(type type),
|
80
|
+
33 => %w(rate session_rate),
|
81
|
+
34 => %w(rate_lim session_rate_limit),
|
82
|
+
35 => %w(rate_max session_rate_max),
|
83
|
+
36 => %w(check_status check_status),
|
84
|
+
37 => %w(check_code check_code),
|
85
|
+
38 => %w(check_duration healthcheck_duration),
|
86
|
+
39 => %w(hrsp_1xx response_1xx),
|
87
|
+
40 => %w(hrsp_2xx response_2xx),
|
88
|
+
41 => %w(hrsp_3xx response_3xx),
|
89
|
+
42 => %w(hrsp_4xx response_4xx),
|
90
|
+
43 => %w(hrsp_5xx response_5xx),
|
91
|
+
44 => %w(hrsp_other response_other),
|
92
|
+
45 => %w(hanafail failed_healthcheck_details),
|
93
|
+
46 => %w(req_rate requests_per_second),
|
94
|
+
47 => %w(req_rate_max requests_per_second_max),
|
95
|
+
48 => %w(req_tot requests_total),
|
96
|
+
49 => %w(cli_abrt trasfer_aborts_client),
|
97
|
+
50 => %w(srv_abrt trasfer_aborts_server),
|
98
|
+
51 => %w(comp_in compressor_in),
|
99
|
+
52 => %w(comp_out compressor_out),
|
100
|
+
53 => %w(comp_byp compressor_bytes),
|
101
|
+
54 => %w(comp_rsp compressor_responses),
|
102
|
+
55 => %w(lastsess session_last_assigned_seconds),
|
103
|
+
56 => %w(last_chk healthcheck_contents),
|
104
|
+
57 => %w(last_agt agent_check_contents),
|
105
|
+
58 => %w(qtime queue_time),
|
106
|
+
59 => %w(ctime connect_time),
|
107
|
+
60 => %w(rtime response_time),
|
108
|
+
61 => %w(ttime average_time),
|
109
|
+
62 => %w(agent_status agent_status),
|
110
|
+
63 => %w(agent_code agent_code),
|
111
|
+
64 => %w(agent_duration agent_duration),
|
112
|
+
65 => %w(check_desc check_desc),
|
113
|
+
66 => %w(agent_desc agent_desc),
|
114
|
+
67 => %w(check_rise check_rise),
|
115
|
+
68 => %w(check_fall check_fall),
|
116
|
+
69 => %w(check_health check_health),
|
117
|
+
70 => %w(agent_rise agent_rise),
|
118
|
+
71 => %w(agent_fall agent_fall),
|
119
|
+
72 => %w(agent_health agent_health),
|
120
|
+
73 => %w(addr address),
|
121
|
+
74 => %w(cookie cookie),
|
122
|
+
75 => %w(mode mode),
|
123
|
+
76 => %w(algo algorithm),
|
124
|
+
77 => %w(conn_rate conn_rate),
|
125
|
+
78 => %w(conn_rate_max conn_rate_max),
|
126
|
+
79 => %w(conn_tot conn_tot),
|
127
|
+
80 => %w(intercepted requests_intercepted),
|
128
|
+
81 => %w(dcon requests_denied_connection),
|
129
|
+
82 => %w(dses requests_denied_session)
|
130
|
+
}.freeze
|
131
|
+
NON_NUMERIC_FIELDS = [0, 1, 17, 26, 27, 28, 31, 32, 36, 37, 45, 56, 57, 62, 63, 65, 66, 73, 74, 75, 76].freeze
|
132
|
+
|
37
133
|
option :connection,
|
38
134
|
short: '-c HOSTNAME|SOCKETPATH',
|
39
135
|
long: '--connect HOSTNAME|SOCKETPATH',
|
@@ -102,6 +198,25 @@ class HAProxyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
102
198
|
default: 1,
|
103
199
|
proc: proc(&:to_i)
|
104
200
|
|
201
|
+
option :expose_all,
|
202
|
+
description: 'Expose all possible metrics, includes "--server-metrics", "--backends" will still in effect',
|
203
|
+
short: '-a',
|
204
|
+
long: '--expose-all',
|
205
|
+
boolean: true,
|
206
|
+
default: false
|
207
|
+
|
208
|
+
option :use_haproxy_names,
|
209
|
+
description: 'Use raw names as used in haproxy CSV format definition rather than human friendly names',
|
210
|
+
long: '--use-haproxy-names',
|
211
|
+
boolean: true,
|
212
|
+
default: false
|
213
|
+
|
214
|
+
option :use_explicit_names,
|
215
|
+
description: 'Use explicit names for frontend, backend, server, listener',
|
216
|
+
long: '--use-explicit-names',
|
217
|
+
boolean: true,
|
218
|
+
default: false
|
219
|
+
|
105
220
|
def acquire_stats
|
106
221
|
uri = URI.parse(config[:connection])
|
107
222
|
|
@@ -125,11 +240,30 @@ class HAProxyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
125
240
|
return nil
|
126
241
|
end
|
127
242
|
|
128
|
-
def
|
129
|
-
|
243
|
+
def render_output(type, pxname, svname, index, value)
|
244
|
+
return if value.nil?
|
245
|
+
field_index = config[:use_haproxy_names] ? 0 : 1
|
246
|
+
field_name = CSV_FIELDS[index][field_index]
|
247
|
+
if config[:use_explicit_names]
|
248
|
+
if type == TYPE_FRONTEND
|
249
|
+
output "#{config[:scheme]}.frontend.#{pxname}.#{field_name}", value
|
250
|
+
elsif type == TYPE_BACKEND
|
251
|
+
output "#{config[:scheme]}.backend.#{pxname}.#{field_name}", value
|
252
|
+
elsif type == TYPE_SERVER
|
253
|
+
output "#{config[:scheme]}.backend.#{pxname}.server.#{svname}.#{field_name}", value
|
254
|
+
elsif type == TYPE_LISTENER
|
255
|
+
output "#{config[:scheme]}.listener.#{pxname}.#{svname}.#{field_name}", value
|
256
|
+
end
|
257
|
+
else
|
258
|
+
if type == TYPE_BACKEND # rubocop:disable IfInsideElse
|
259
|
+
output "#{config[:scheme]}.#{pxname}.#{field_name}", value
|
260
|
+
else
|
261
|
+
output "#{config[:scheme]}.#{pxname}.#{svname}.#{field_name}", value
|
262
|
+
end
|
263
|
+
end
|
130
264
|
end
|
131
265
|
|
132
|
-
def run
|
266
|
+
def run
|
133
267
|
out = nil
|
134
268
|
1.upto(config[:retries]) do |_i|
|
135
269
|
out = acquire_stats
|
@@ -145,50 +279,36 @@ class HAProxyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
145
279
|
parsed = CSV.parse(out)
|
146
280
|
parsed.shift
|
147
281
|
parsed.each do |line|
|
282
|
+
pxname = line[0]
|
283
|
+
svname = line[1]
|
284
|
+
type = line[32]
|
285
|
+
|
148
286
|
if config[:backends].length > 0
|
149
287
|
next unless config[:backends].include? line[0]
|
150
288
|
end
|
151
289
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
output "#{config[:scheme]}.#{line[0]}.connection_errors", line[13]
|
158
|
-
output "#{config[:scheme]}.#{line[0]}.warning_retries", line[15]
|
159
|
-
output "#{config[:scheme]}.#{line[0]}.warning_redispatched", line[16]
|
160
|
-
output "#{config[:scheme]}.#{line[0]}.response_1xx", line[39]
|
161
|
-
output "#{config[:scheme]}.#{line[0]}.response_2xx", line[40]
|
162
|
-
output "#{config[:scheme]}.#{line[0]}.response_3xx", line[41]
|
163
|
-
output "#{config[:scheme]}.#{line[0]}.response_4xx", line[42]
|
164
|
-
output "#{config[:scheme]}.#{line[0]}.response_5xx", line[43]
|
165
|
-
output "#{config[:scheme]}.#{line[0]}.response_other", line[44]
|
166
|
-
unless line[46].nil?
|
167
|
-
output "#{config[:scheme]}.#{line[0]}.requests_per_second", line[46]
|
168
|
-
end
|
169
|
-
unless line[47].nil?
|
170
|
-
output "#{config[:scheme]}.#{line[0]}.requests_per_second_max", line[47]
|
171
|
-
end
|
172
|
-
output "#{config[:scheme]}.#{line[0]}.queue_time", line[58]
|
173
|
-
output "#{config[:scheme]}.#{line[0]}.connect_time", line[59]
|
174
|
-
output "#{config[:scheme]}.#{line[0]}.response_time", line[60]
|
175
|
-
output "#{config[:scheme]}.#{line[0]}.average_time", line[61]
|
290
|
+
indices = []
|
291
|
+
if config[:expose_all]
|
292
|
+
indices = CSV_FIELDS.keys - NON_NUMERIC_FIELDS
|
293
|
+
elsif type == TYPE_BACKEND
|
294
|
+
indices = [4, 7, 8, 9, 13, 15, 16, 39, 40, 41, 42, 43, 44, 46, 47, 58, 59, 60, 61]
|
176
295
|
elsif config[:server_metrics]
|
177
|
-
|
178
|
-
output "#{config[:scheme]}.#{line[0]}.#{line[1]}.session_current", line[4]
|
179
|
-
output "#{config[:scheme]}.#{line[0]}.#{line[1]}.requests_per_second", line[46]
|
180
|
-
output "#{config[:scheme]}.#{line[0]}.#{line[1]}.requests_per_second_max", line[47]
|
181
|
-
output "#{config[:scheme]}.#{line[0]}.#{line[1]}.requests_total", line[48]
|
296
|
+
indices = [4, 7, 46, 47, 48]
|
182
297
|
end
|
298
|
+
indices.each { |i| render_output type, pxname, svname, i, line[i] }
|
183
299
|
|
184
|
-
if
|
185
|
-
up_by_backend[
|
186
|
-
up_by_backend[
|
300
|
+
if type == TYPE_SERVER
|
301
|
+
up_by_backend[pxname] ||= 0
|
302
|
+
up_by_backend[pxname] += line[17].start_with?('UP') ? 1 : 0
|
187
303
|
end
|
188
304
|
end
|
189
305
|
|
190
306
|
up_by_backend.each_pair do |backend, count|
|
191
|
-
|
307
|
+
if config[:use_explicit_names]
|
308
|
+
output "#{config[:scheme]}.backend.#{backend}.num_up", count
|
309
|
+
else
|
310
|
+
output "#{config[:scheme]}.#{backend}.num_up", count
|
311
|
+
end
|
192
312
|
end
|
193
313
|
|
194
314
|
ok
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-haproxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
197
|
+
rubygems_version: 2.6.13
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Sensu plugins for haproxy
|