sensu-plugins-aws 14.0.0 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4c125fe85336325c696743b86e583d8dd5f15bc
4
- data.tar.gz: f47506bebde25ee38b67630caa56c79b6fe17beb
3
+ metadata.gz: 88538012dc8a180460b5940bcdd1da6888a589c5
4
+ data.tar.gz: 6c54d7bf29e80f548b3ea9c82500c8ba92d8e98a
5
5
  SHA512:
6
- metadata.gz: 41a57b823a533d2c30ae145e7a23ca7f5b4ab96103d648cf2f030efbd7bc12215c0e1ceaabbbd07f5d05d9e3c1a024d07c6cf074332c28d69bc177c076295cea
7
- data.tar.gz: 75858702513638477429cc66226c8442ccf71d655f570105f3e7785d9d02f34be51368bac69dccfc122c5d9bffe879339707ca3e4aa60305ae70775d6c5cd31f
6
+ metadata.gz: a6d595483bf559aa7a2e647f7cb01100fa5cdfb99bf2eba5c6e74b6b4f59fe047e452e0c5c603c1b2b062b2e5d724adead5c012b49fce7419f2297e748ab2987
7
+ data.tar.gz: 794ca978c9026de692fcdb46bc1fd4ee357f1d404fbfb7898dafb89afd7ce0e86d667cda1b73434ede27f8921c69d770b66619b6bd2d9bd2e5d90356b2eb5ddc
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [15.0.0] - 2018-11-01
9
+ ### Breaking Changes
10
+ - `check-elb-latency.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
11
+ ### Changed
12
+ - `check-elb-latency.rb` was updated to aws-sdk v2. (@boutetnico)
13
+
8
14
  ## [14.0.0] - 2018-11-01
9
15
  ### Breaking Changes
10
16
  - `check-elb-sum-requests.rb` no longer takes `aws_access_key` and `aws_secret_access_key` options. (@boutetnico)
@@ -520,7 +526,8 @@ WARNING: This release contains major breaking changes that will impact all user
520
526
  ### Added
521
527
  - initial release
522
528
 
523
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/14.0.0...HEAD
529
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/15.0.0...HEAD
530
+ [15.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/14.0.0...15.0.0
524
531
  [14.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/13.0.0...14.0.0
525
532
  [13.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.4.0...13.0.0
526
533
  [12.4.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/12.3.0...12.4.0
@@ -4,7 +4,7 @@
4
4
  #
5
5
  #
6
6
  # DESCRIPTION:
7
- # This plugin checks the health of an Amazon Elastic Load Balancer.
7
+ # This plugin checks the latency of an Amazon Elastic Load Balancer.
8
8
  #
9
9
  # OUTPUT:
10
10
  # plain-text
@@ -13,7 +13,7 @@
13
13
  # Linux
14
14
  #
15
15
  # DEPENDENCIES:
16
- # gem: aws-sdk-v1
16
+ # gem: aws-sdk
17
17
  # gem: sensu-plugin
18
18
  #
19
19
  # USAGE:
@@ -32,20 +32,11 @@
32
32
  #
33
33
 
34
34
  require 'sensu-plugin/check/cli'
35
- require 'aws-sdk-v1'
35
+ require 'sensu-plugins-aws'
36
+ require 'aws-sdk'
36
37
 
37
38
  class CheckELBLatency < Sensu::Plugin::Check::CLI
38
- option :aws_access_key,
39
- short: '-a AWS_ACCESS_KEY',
40
- long: '--aws-access-key AWS_ACCESS_KEY',
41
- description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
42
- default: ENV['AWS_ACCESS_KEY']
43
-
44
- option :aws_secret_access_key,
45
- short: '-k AWS_SECRET_KEY',
46
- long: '--aws-secret-access-key AWS_SECRET_KEY',
47
- description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
48
- default: ENV['AWS_SECRET_KEY']
39
+ include Common
49
40
 
50
41
  option :aws_region,
51
42
  short: '-r AWS_REGION',
@@ -87,42 +78,41 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
87
78
  description: "Trigger a #{severity} if latancy is over specified seconds"
88
79
  end
89
80
 
90
- def aws_config
91
- { access_key_id: config[:aws_access_key],
92
- secret_access_key: config[:aws_secret_access_key],
93
- region: config[:aws_region] }
94
- end
95
-
96
81
  def elb
97
- @elb ||= AWS::ELB.new aws_config
82
+ @elb ||= Aws::ElasticLoadBalancing::Client.new(aws_config)
98
83
  end
99
84
 
100
85
  def cloud_watch
101
- @cloud_watch ||= AWS::CloudWatch.new aws_config
86
+ @cloud_watch ||= Aws::CloudWatch::Client.new
102
87
  end
103
88
 
104
89
  def elbs
105
90
  return @elbs if @elbs
106
- @elbs = elb.load_balancers.to_a
107
- @elbs.select! { |elb| config[:elb_names].include? elb.name } if config[:elb_names]
91
+ @elbs = elb.describe_load_balancers.load_balancer_descriptions.to_a
92
+ @elbs.select! { |elb| config[:elb_names].include? elb.load_balancer_name } if config[:elb_names]
108
93
  @elbs
109
94
  end
110
95
 
111
96
  def latency_metric(elb_name)
112
- cloud_watch.metrics.with_namespace('AWS/ELB').with_metric_name('Latency').with_dimensions(name: 'LoadBalancerName', value: elb_name).first
113
- end
114
-
115
- def statistics_options
116
- {
97
+ cloud_watch.get_metric_statistics(
98
+ namespace: 'AWS/ELB',
99
+ metric_name: 'Latency',
100
+ dimensions: [
101
+ {
102
+ name: 'LoadBalancerName',
103
+ value: elb_name
104
+ }
105
+ ],
117
106
  start_time: config[:end_time] - config[:period],
118
- end_time: config[:end_time],
107
+ end_time: config[:end_time],
119
108
  statistics: [config[:statistics].to_s.capitalize],
120
- period: config[:period]
121
- }
109
+ period: config[:period],
110
+ unit: 'Seconds'
111
+ )
122
112
  end
123
113
 
124
114
  def latest_value(metric)
125
- metric.statistics(statistics_options.merge(unit: 'Seconds')).datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[config[:statistics]]
115
+ metric.datapoints.sort_by { |datapoint| datapoint[:timestamp] }.last[config[:statistics]]
126
116
  end
127
117
 
128
118
  def flag_alert(severity, message)
@@ -131,7 +121,7 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
131
121
  end
132
122
 
133
123
  def check_latency(elb)
134
- metric = latency_metric elb.name
124
+ metric = latency_metric elb.load_balancer_name
135
125
  metric_value = begin
136
126
  latest_value metric
137
127
  rescue StandardError
@@ -143,14 +133,14 @@ class CheckELBLatency < Sensu::Plugin::Check::CLI
143
133
  next unless threshold
144
134
  next if metric_value < threshold
145
135
  flag_alert severity,
146
- "; #{elbs.size == 1 ? nil : "#{elb.inspect}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})"
136
+ "; #{elbs.size == 1 ? nil : "#{elb.load_balancer_name}'s"} Latency is #{sprintf '%.3f', metric_value} seconds. (expected lower than #{sprintf '%.3f', threshold})"
147
137
  break
148
138
  end
149
139
  end
150
140
 
151
141
  def run
152
142
  @message = if elbs.size == 1
153
- elbs.first.inspect
143
+ elbs.first.load_balancer_name
154
144
  else
155
145
  "#{elbs.size} load balancers total"
156
146
  end
@@ -1,6 +1,6 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
- MAJOR = 14
3
+ MAJOR = 15
4
4
  MINOR = 0
5
5
  PATCH = 0
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors