sensu-plugins-edgelab 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/metrics-elb.rb +161 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f4873000006af1ae4e2d3a50b0224f846580071
|
4
|
+
data.tar.gz: 7a87b35a86c7cd91077f889575e7cb3bf6335a37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e7b86ef303fc7e7092ac5adc90c0c5dc1af6aa3ad2bfdce95d0f232070cea3d91b68ece7b6c4ca3bb6206e988c84e82d8ff25d07c31458fef13a51a21da715a
|
7
|
+
data.tar.gz: 654dbd0d169f50e4c8af3320599cac010e54b2c194097d76e5028cd9aa21e2b874d222ce2d4d76a4470f1d6f577aa3e49cb55386539063994f071c0566fb72d8
|
data/bin/metrics-elb.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# elb-metrics
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Gets latency metrics from CloudWatch and puts them in Graphite for longer term storage
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric-data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: aws-sdk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
# gem: sensu-plugin-aws
|
18
|
+
# gem: time
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# #YELLOW
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
# Returns latency statistics by default. You can specify any valid ELB metric type, see
|
25
|
+
# http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html#elb-metricscollected
|
26
|
+
#
|
27
|
+
# By default fetches statistics from one minute ago. You may need to fetch further back than this;
|
28
|
+
# high traffic ELBs can sometimes experience statistic delays of up to 10 minutes. If you experience this,
|
29
|
+
# raising a ticket with AWS support should get the problem resolved.
|
30
|
+
# As a workaround you can use eg -f 300 to fetch data from 5 minutes ago.
|
31
|
+
#
|
32
|
+
# LICENSE:
|
33
|
+
# Copyright 2013 Bashton Ltd http://www.bashton.com/
|
34
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
35
|
+
# for details.
|
36
|
+
# Updated by Peter Hoppe <peter.hoppe.extern@bertelsmann.de> 09.11.2016
|
37
|
+
# Using aws sdk version 2
|
38
|
+
|
39
|
+
require 'sensu-plugin/metric/cli'
|
40
|
+
require 'aws-sdk'
|
41
|
+
require 'sensu-plugins-aws'
|
42
|
+
require 'time'
|
43
|
+
|
44
|
+
class ELBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
45
|
+
include Common
|
46
|
+
option :elbname,
|
47
|
+
description: 'Name of the Elastic Load Balancer',
|
48
|
+
short: '-n ELB_NAME',
|
49
|
+
long: '--name ELB_NAME'
|
50
|
+
|
51
|
+
option :scheme,
|
52
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
53
|
+
short: '-s SCHEME',
|
54
|
+
long: '--scheme SCHEME',
|
55
|
+
default: ''
|
56
|
+
|
57
|
+
option :fetch_age,
|
58
|
+
description: 'How long ago to fetch metrics for',
|
59
|
+
short: '-f AGE',
|
60
|
+
long: '--fetch_age',
|
61
|
+
default: 60,
|
62
|
+
proc: proc(&:to_i)
|
63
|
+
|
64
|
+
option :statistic,
|
65
|
+
description: 'Statistics type',
|
66
|
+
short: '-t STATISTIC',
|
67
|
+
long: '--statistic',
|
68
|
+
default: ''
|
69
|
+
|
70
|
+
option :aws_region,
|
71
|
+
short: '-r AWS_REGION',
|
72
|
+
long: '--aws-region REGION',
|
73
|
+
description: 'AWS Region (defaults to us-east-1).',
|
74
|
+
default: ENV['AWS_REGION']
|
75
|
+
|
76
|
+
option :end_time,
|
77
|
+
short: '-t T',
|
78
|
+
long: '--end-time TIME',
|
79
|
+
default: Time.now,
|
80
|
+
proc: proc { |a| Time.parse a },
|
81
|
+
description: 'CloudWatch metric statistics end time'
|
82
|
+
|
83
|
+
option :period,
|
84
|
+
short: '-p N',
|
85
|
+
long: '--period SECONDS',
|
86
|
+
default: 60,
|
87
|
+
proc: proc(&:to_i),
|
88
|
+
description: 'CloudWatch metric statistics period'
|
89
|
+
|
90
|
+
def cloud_watch
|
91
|
+
@cloud_watch = Aws::CloudWatch::Client.new
|
92
|
+
end
|
93
|
+
|
94
|
+
def loadbalancer
|
95
|
+
@loadbalancer = Aws::ElasticLoadBalancing::Client.new
|
96
|
+
end
|
97
|
+
|
98
|
+
def cloud_watch_metric(metric_name, value, load_balancer_name)
|
99
|
+
cloud_watch.get_metric_statistics(
|
100
|
+
namespace: 'AWS/ELB',
|
101
|
+
metric_name: metric_name,
|
102
|
+
dimensions: [
|
103
|
+
{
|
104
|
+
name: 'LoadBalancerName',
|
105
|
+
value: load_balancer_name
|
106
|
+
}
|
107
|
+
],
|
108
|
+
statistics: [value],
|
109
|
+
start_time: config[:end_time] - config[:period],
|
110
|
+
end_time: config[:end_time],
|
111
|
+
period: config[:period]
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
def print_statistics(load_balancer_name, statistics)
|
116
|
+
result = {}
|
117
|
+
static_value = {}
|
118
|
+
statistics.each do |key, static|
|
119
|
+
r = cloud_watch_metric(key, static, load_balancer_name)
|
120
|
+
static_value[config[:scheme] + '.' + 'loadbalancer.' + load_balancer_name + '.' + key + '.' + static] = static
|
121
|
+
result[config[:scheme] + '.' + 'loadbalancer.' + load_balancer_name + '.' + key + '.' + static] = r[:datapoints][0] unless r[:datapoints][0].nil?
|
122
|
+
end
|
123
|
+
result.each do |key, value|
|
124
|
+
output key.downcase.to_s, value[static_value[key].downcase], value[:timestamp].to_i
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def run
|
129
|
+
if config[:statistic] == ''
|
130
|
+
default_statistic_per_metric = {
|
131
|
+
'Latency' => 'Average',
|
132
|
+
'RequestCount' => 'Sum',
|
133
|
+
'UnHealthyHostCount' => 'Average',
|
134
|
+
'HealthyHostCount' => 'Average',
|
135
|
+
'HTTPCode_Backend_2XX' => 'Sum',
|
136
|
+
'HTTPCode_Backend_3XX' => 'Sum',
|
137
|
+
'HTTPCode_Backend_4XX' => 'Sum',
|
138
|
+
'HTTPCode_Backend_5XX' => 'Sum',
|
139
|
+
'HTTPCode_ELB_4XX' => 'Sum',
|
140
|
+
'HTTPCode_ELB_5XX' => 'Sum',
|
141
|
+
'BackendConnectionErrors' => 'Sum',
|
142
|
+
'SurgeQueueLength' => 'Maximum',
|
143
|
+
'SpilloverCount' => 'Sum'
|
144
|
+
}
|
145
|
+
statistic = default_statistic_per_metric
|
146
|
+
else
|
147
|
+
statistic = config[:statistic]
|
148
|
+
end
|
149
|
+
|
150
|
+
begin
|
151
|
+
if config[:elbname].nil?
|
152
|
+
loadbalancer.describe_load_balancers.load_balancer_descriptions.each do |elb|
|
153
|
+
print_statistics(elb.load_balancer_name, statistic)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
print_statistics(config[:elbname], statistic)
|
157
|
+
end
|
158
|
+
ok
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: diplomat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.14.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.14.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: inifile
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +144,7 @@ executables:
|
|
130
144
|
- check-swarm-cluster.rb
|
131
145
|
- metrics-asg.rb
|
132
146
|
- check-nomad-leader.rb
|
147
|
+
- metrics-elb.rb
|
133
148
|
- check-apt-expired-keys.rb
|
134
149
|
- metrics-swarm-cluster.rb
|
135
150
|
- metrics-mysql-processes.rb
|
@@ -141,6 +156,7 @@ files:
|
|
141
156
|
- bin/check-nomad-leader.rb
|
142
157
|
- bin/check-swarm-cluster.rb
|
143
158
|
- bin/metrics-asg.rb
|
159
|
+
- bin/metrics-elb.rb
|
144
160
|
- bin/metrics-mysql-processes.rb
|
145
161
|
- bin/metrics-rds.rb
|
146
162
|
- bin/metrics-swarm-cluster.rb
|