sensu-plugins-edgelab 1.15.1 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/metrics-alb.rb +162 -0
- metadata +33 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5ae185b0178726421cb6424a2520cbda7097bb27b95032cbf6ab936effd88bf
|
4
|
+
data.tar.gz: e7c6d24454546237899cd3fa42dc02364132a78c82bf1f01cfbc312478523501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 584fde208f1a8d1c5da5838098970d3a7b035469518245b067d904a8dcff10fec6847fca1f40e08a94891b278ad7d34437babd8fa51c8b3c52a62877fc134f58
|
7
|
+
data.tar.gz: ea4dd7edef755088d26b4d1db51891ae3c3d647c68acebf29812f72a294b0a360efa213aa4fc73fd11bf2540f324dc431ea9396fd79eea4604c4b36e8ace4c11
|
data/bin/metrics-alb.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-alb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Gets Application Load Balancer metrics from CloudWatch and puts them in
|
7
|
+
# Graphite for longer term storage
|
8
|
+
#
|
9
|
+
# OUTPUT:
|
10
|
+
# metric-data
|
11
|
+
#
|
12
|
+
# PLATFORMS:
|
13
|
+
# Linux
|
14
|
+
#
|
15
|
+
# DEPENDENCIES:
|
16
|
+
# gem: aws-sdk
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: sensu-plugin-aws
|
19
|
+
# gem: time
|
20
|
+
#
|
21
|
+
# USAGE:
|
22
|
+
# #YELLOW
|
23
|
+
#
|
24
|
+
# NOTES:
|
25
|
+
# By default fetches statistics from one minute ago. You may need to fetch
|
26
|
+
# further back than this; high traffic load balancers can sometimes
|
27
|
+
# experience statistic delays of up to 10 minutes. If you experience this,
|
28
|
+
# raising a ticket with AWS support should get the problem resolved.
|
29
|
+
# As a workaround you can use eg -f 300 to fetch data from 5 minutes ago.
|
30
|
+
#
|
31
|
+
# LICENSE:
|
32
|
+
# Copyright 2018 Jonathan Ballet <jon@multani.info>
|
33
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
34
|
+
# for details.
|
35
|
+
|
36
|
+
require 'sensu-plugin/metric/cli'
|
37
|
+
require 'aws-sdk'
|
38
|
+
require 'sensu-plugins-aws'
|
39
|
+
require 'time'
|
40
|
+
|
41
|
+
class ALBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
42
|
+
include CloudwatchCommon
|
43
|
+
|
44
|
+
option :albname,
|
45
|
+
description: 'Name of the Application Load Balancer',
|
46
|
+
short: '-n ALB_NAME',
|
47
|
+
long: '--name ALB_NAME'
|
48
|
+
|
49
|
+
option :scheme,
|
50
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
51
|
+
short: '-s SCHEME',
|
52
|
+
long: '--scheme SCHEME',
|
53
|
+
default: 'alb'
|
54
|
+
|
55
|
+
option :fetch_age,
|
56
|
+
description: 'How long ago to fetch metrics for',
|
57
|
+
short: '-f AGE',
|
58
|
+
long: '--fetch-age',
|
59
|
+
default: 60,
|
60
|
+
proc: proc(&:to_i)
|
61
|
+
|
62
|
+
option :aws_region,
|
63
|
+
short: '-r AWS_REGION',
|
64
|
+
long: '--aws-region REGION',
|
65
|
+
description: 'AWS Region (defaults to the AWS_REGION variable)',
|
66
|
+
default: ENV['AWS_REGION']
|
67
|
+
|
68
|
+
option :end_time,
|
69
|
+
short: '-t TIME',
|
70
|
+
long: '--end-time TIME',
|
71
|
+
default: Time.now,
|
72
|
+
proc: proc { |a| Time.parse a },
|
73
|
+
description: 'CloudWatch metric statistics end time'
|
74
|
+
|
75
|
+
option :period,
|
76
|
+
short: '-p SECONDS',
|
77
|
+
long: '--period SECONDS',
|
78
|
+
default: 60,
|
79
|
+
proc: proc(&:to_i),
|
80
|
+
description: 'CloudWatch metric statistics period'
|
81
|
+
|
82
|
+
def loadbalancer
|
83
|
+
@loadbalancer = Aws::ElasticLoadBalancingV2::Client.new
|
84
|
+
end
|
85
|
+
|
86
|
+
def cloud_watch_metric(metric_name, value, load_balancer_name, alb_id)
|
87
|
+
name = ['app', load_balancer_name, alb_id].join('/')
|
88
|
+
client.get_metric_statistics(
|
89
|
+
namespace: 'AWS/ApplicationELB',
|
90
|
+
metric_name: metric_name,
|
91
|
+
dimensions: [
|
92
|
+
{
|
93
|
+
name: 'LoadBalancer',
|
94
|
+
value: name
|
95
|
+
}
|
96
|
+
],
|
97
|
+
statistics: [value],
|
98
|
+
start_time: config[:end_time] - config[:fetch_age] - config[:period],
|
99
|
+
end_time: config[:end_time] - config[:fetch_age],
|
100
|
+
period: config[:period]
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def print_statistics(load_balancer_name, alb_id, statistics)
|
105
|
+
result = {}
|
106
|
+
static_value = {}
|
107
|
+
statistics.each do |key, static|
|
108
|
+
r = cloud_watch_metric(key, static, load_balancer_name, alb_id)
|
109
|
+
keys = if config[:scheme] == ''
|
110
|
+
[]
|
111
|
+
else
|
112
|
+
[config[:scheme]]
|
113
|
+
end
|
114
|
+
keys.concat [load_balancer_name, key, static]
|
115
|
+
metric_key = keys.join('.')
|
116
|
+
|
117
|
+
static_value[metric_key] = static
|
118
|
+
result[metric_key] = r[:datapoints][0] unless r[:datapoints][0].nil?
|
119
|
+
end
|
120
|
+
result.each do |key, value|
|
121
|
+
output key, value[static_value[key].downcase], value[:timestamp].to_i
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def run
|
126
|
+
statistics = {
|
127
|
+
'ActiveConnectionCount' => 'Sum',
|
128
|
+
'ClientTLSNegotiationErrorCount' => 'Sum',
|
129
|
+
'ConsumedLCUs' => 'Sum',
|
130
|
+
'HTTPCode_ELB_4XX_Count' => 'Sum',
|
131
|
+
'HTTPCode_ELB_5XX_Count' => 'Sum',
|
132
|
+
'HTTPCode_Target_2XX_Count' => 'Sum',
|
133
|
+
'HTTPCode_Target_3XX_Count' => 'Sum',
|
134
|
+
'HTTPCode_Target_4XX_Count' => 'Sum',
|
135
|
+
'HTTPCode_Target_5XX_Count' => 'Sum',
|
136
|
+
'IPv6ProcessedBytes' => 'Sum',
|
137
|
+
'IPv6RequestCount' => 'Sum',
|
138
|
+
'NewConnectionCount' => 'Sum',
|
139
|
+
'ProcessedBytes' => 'Sum',
|
140
|
+
'RejectedConnectionCount' => 'Sum',
|
141
|
+
'RequestCount' => 'Sum',
|
142
|
+
'RuleEvaluations' => 'Sum',
|
143
|
+
'TargetConnectionErrorCount' => 'Sum',
|
144
|
+
'TargetResponseTime' => 'Average',
|
145
|
+
'TargetTLSNegotiationErrorCount' => 'Sum',
|
146
|
+
|
147
|
+
# The following metrics have a different dimension than the others:
|
148
|
+
# 'HealthyHostCount' => 'Average', # Dimension=TargetGroup+LoadBalancer
|
149
|
+
# 'RequestCountPerTarget' => 'Sum', # Dimension=TargetGroup
|
150
|
+
# 'UnHealthyHostCount' => 'Average', # Dimension=TargetGroup+LoadBalancer
|
151
|
+
}
|
152
|
+
|
153
|
+
begin
|
154
|
+
loadbalancer.describe_load_balancers.load_balancers.each do |alb|
|
155
|
+
next unless config[:albname].nil? || config[:albname] == alb.load_balancer_name
|
156
|
+
alb_id = alb.load_balancer_arn.split(':').last.split('/').last
|
157
|
+
print_statistics(alb.load_balancer_name, alb_id, statistics)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
ok
|
161
|
+
end
|
162
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws-sdk
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.3'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.3'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: cassandra-driver
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +108,34 @@ dependencies:
|
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '2.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: aws-sdk
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sensu-plugins-aws
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 11.5.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 11.5.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: bundler
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +189,7 @@ executables:
|
|
175
189
|
- check-nomad-leader.rb
|
176
190
|
- check-swarm-cluster.rb
|
177
191
|
- handler-multi-hipchat.rb
|
192
|
+
- metrics-alb.rb
|
178
193
|
- metrics-cassandra-basic.rb
|
179
194
|
- metrics-es-indices.rb
|
180
195
|
- metrics-redis-key-pattern.rb
|
@@ -190,6 +205,7 @@ files:
|
|
190
205
|
- bin/check-nomad-leader.rb
|
191
206
|
- bin/check-swarm-cluster.rb
|
192
207
|
- bin/handler-multi-hipchat.rb
|
208
|
+
- bin/metrics-alb.rb
|
193
209
|
- bin/metrics-cassandra-basic.rb
|
194
210
|
- bin/metrics-es-indices.rb
|
195
211
|
- bin/metrics-redis-key-pattern.rb
|
@@ -213,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
229
|
version: '0'
|
214
230
|
requirements: []
|
215
231
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.7.
|
232
|
+
rubygems_version: 2.7.7
|
217
233
|
signing_key:
|
218
234
|
specification_version: 4
|
219
235
|
summary: Contains Edgelab plugins for Sensu
|