sensu-plugins-aws 16.2.0 → 17.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
  SHA256:
3
- metadata.gz: d3d17caf7ac0047d02b2d9f339fcc7a445f88492c23ac96a5da4ffc957740c29
4
- data.tar.gz: a67fa60ca62797968ddab4bb33d899dba1b4c8a1aeac2a676eef3babc24f5bd1
3
+ metadata.gz: b05e0394036396881a2c21bdf8c448eb856c59ce2d6b823552bcca6bbdcc6d7f
4
+ data.tar.gz: 1ee23068ea1c8d72f2fcf549baa0213cb2d4beda05664861890302a26caf50e0
5
5
  SHA512:
6
- metadata.gz: 593b2de9a5809ca5cabb4f0e56effca1bee0b9b5a9392c9dca61ca95fd6df3b1fc2d83510739924649a60165f63ee2928fc165203fe414b3a05e705172953c3a
7
- data.tar.gz: ec57ca98fa34966aa253194585b38c2294da22a6a014a1abeb0461b523043d8dfe65e2b0077147d47dfa26301bce3c16beee416c692139efdc5898cbe80fd855
6
+ metadata.gz: 63e63fa98ee696e071f56809357695c80a206618964b0dc85f160d87e42bd8db2c693b97622d82f66153205d8ce4a42b4113589e1496e15a0ead826c0a4ce74e
7
+ data.tar.gz: f3313e41ad7cf05d9c2717a60cca0061cacbf9bcd3a2734678fa358595f4928c2841615e3212a3f5866798a7f7d2e5c4d0b42d416e12c04af2679b3663babe5b
data/CHANGELOG.md CHANGED
@@ -4,10 +4,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [17.0.0] - 2019-03-26
8
+ ### Breaking Changes
9
+ - `metrics-cloudfront.rb` `--metric` option was renamed to `--metrics`. (@boutetnico)
10
+
11
+ ### Added
12
+ - `check-sqs-messages.rb`: adding option `--exclude-queues` for use in blacklisting specific queues in conjunction with `--prefix` flag. (@ruke47)
13
+
14
+ ### Changed
15
+ - `metrics-cloudfront.rb` now accepts multiple metrics. (@boutetnico)
7
16
 
8
17
  ## [16.2.0] - 2019-02-19
9
18
  ### Fixed
10
19
  - removed codeclimate (@tmonk42)
20
+ - properly iterate over IPs in check-vpc-nameservers.rb (@masneyb)
11
21
 
12
22
  ### Added
13
23
  - `check-ec2-cpu_balance.rb`: adding option `--instance-families` to manage which instance families to check. (@cyrilgdn)
@@ -543,7 +553,8 @@ WARNING: This release contains major breaking changes that will impact all user
543
553
  ### Added
544
554
  - initial release
545
555
 
546
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/16.2.0...HEAD
556
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/17.0.0...HEAD
557
+ [17.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/16.2.0...17.0.0
547
558
  [16.2.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/16.1.0...16.2.0
548
559
  [16.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/16.0.0...16.1.0
549
560
  [16.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/15.0.0...16.0.0
@@ -43,11 +43,19 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
43
43
  description: 'AWS Region (defaults to us-east-1).',
44
44
  default: 'us-east-1'
45
45
 
46
- option :queue,
46
+ option :queues,
47
47
  short: '-q SQS_QUEUE',
48
48
  long: '--queue SQS_QUEUE',
49
49
  description: 'A comma seperated list of the SQS queue(s) you want to check the number of messages for',
50
- default: ''
50
+ default: [],
51
+ proc: proc { |q| q.split(',') }
52
+
53
+ option :exclude_queues,
54
+ short: '-Q SQS_QUEUES',
55
+ long: '--exclude-queues SQS_QUEUE',
56
+ description: 'A comma separated list of the SQS queue(s) to exclude, if using --prefix',
57
+ default: [],
58
+ proc: proc { |q| q.split(',') }
51
59
 
52
60
  option :prefix,
53
61
  short: '-p PREFIX',
@@ -100,14 +108,14 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
100
108
  sqs = Aws::SQS::Resource.new
101
109
 
102
110
  if config[:prefix].empty?
103
- if config[:queue].empty?
111
+ if config[:queues].empty?
104
112
  critical 'Error, either QUEUE or PREFIX must be specified'
105
113
  end
106
114
 
107
115
  warnings = []
108
116
  crits = []
109
117
  passing = []
110
- queues = config[:queue].split(',')
118
+ queues = config[:queues]
111
119
  queues.each do |q|
112
120
  url = sqs.get_queue_by_name(queue_name: q).url
113
121
  messages = sqs.client.get_queue_attributes(queue_url: url, attribute_names: ['All']).attributes[config[:metric]].to_i
@@ -131,11 +139,14 @@ class SQSMsgs < Sensu::Plugin::Check::CLI
131
139
  warn = false
132
140
  crit = false
133
141
  queues = []
142
+ exclusions = config[:exclude_queues]
134
143
 
135
144
  sqs.queues(queue_name_prefix: config[:prefix]).each do |q|
136
145
  messages = sqs.client.get_queue_attributes(queue_url: q.url, attribute_names: ['All']).attributes[config[:metric]].to_i
137
146
  queue_name = q.attributes['QueueArn'].split(':').last
138
147
 
148
+ next if exclusions.include? queue_name
149
+
139
150
  if (config[:crit_under] >= 0 && messages < config[:crit_under]) || (config[:crit_over] >= 0 && messages > config[:crit_over])
140
151
  crit = true
141
152
  queues << "#{messages} message(s) in #{queue_name} queue"
@@ -65,7 +65,7 @@ class CheckVpcNameservers < Sensu::Plugin::Check::CLI
65
65
  options.dhcp_options.each do |option|
66
66
  option.dhcp_configurations.each do |map|
67
67
  next if map.key != 'domain-name-servers'
68
- map.each_value do |value|
68
+ map.values.each do |value| # rubocop:disable Performance/HashEachMethods
69
69
  ip = value.value
70
70
  config[:queries].each do |query|
71
71
  begin
@@ -36,7 +36,7 @@ require 'time'
36
36
  class CloudFrontMetrics < Sensu::Plugin::Metric::CLI::Graphite
37
37
  include Common
38
38
  option :distribution_id,
39
- description: 'Distribution id of Cloudfront',
39
+ description: 'Distribution id of Cloudfront (defaults to all distributions)',
40
40
  short: '-d DISTRIBUTION_ID',
41
41
  long: '--distribution_id DISTRIBUTION_ID'
42
42
 
@@ -52,11 +52,10 @@ class CloudFrontMetrics < Sensu::Plugin::Metric::CLI::Graphite
52
52
  description: 'AWS Region (defaults to us-east-1).',
53
53
  default: 'us-east-1'
54
54
 
55
- option :metric,
56
- description: 'Metric to fetch',
57
- short: '-m METRIC',
58
- long: '--metric',
59
- in: %w[Requests BytesDownloaded BytesUploaded TotalErrorRate 4xxErrorRate 5xxErrorRate]
55
+ option :metrics,
56
+ description: 'Commas separated list of metric(s) to fetch',
57
+ short: '-m METRIC1,METRIC2',
58
+ long: '--metrics METRIC1,METRIC2'
60
59
 
61
60
  option :end_time,
62
61
  short: '-t T',
@@ -76,7 +75,7 @@ class CloudFrontMetrics < Sensu::Plugin::Metric::CLI::Graphite
76
75
  @cloud_watch ||= Aws::CloudWatch::Client.new
77
76
  end
78
77
 
79
- def cloud_watch_metric(metric_name, value, distribution_id)
78
+ def cloud_watch_metric(metric_name, statistics, distribution_id)
80
79
  cloud_watch.get_metric_statistics(
81
80
  namespace: 'AWS/CloudFront',
82
81
  metric_name: metric_name,
@@ -90,36 +89,36 @@ class CloudFrontMetrics < Sensu::Plugin::Metric::CLI::Graphite
90
89
  value: distribution_id
91
90
  }
92
91
  ],
93
- statistics: [value],
92
+ statistics: [statistics],
94
93
  start_time: config[:end_time] - config[:period],
95
94
  end_time: config[:end_time],
96
95
  period: config[:period]
97
96
  )
98
97
  end
99
98
 
100
- def distribution_list
99
+ def distribution_list(metrics)
101
100
  list_metrics = cloud_watch.list_metrics(
102
101
  namespace: 'AWS/CloudFront'
103
102
  ).metrics
104
103
 
105
- list_metrics = list_metrics.select { |e| e.metric_name == config[:metric] } unless config[:metric].nil?
104
+ list_metrics = list_metrics.select { |e| metrics.include? e.metric_name }
106
105
 
107
106
  list_metrics.reduce(Set.new) do |result, item|
108
107
  result << item.dimensions.find { |element| element.name == 'DistributionId' }.value
109
108
  end
110
109
  end
111
110
 
112
- def print_statistics(distribution_id, statistics)
113
- statistics.each do |key, static|
114
- r = cloud_watch_metric(key, static, distribution_id)
111
+ def print_statistics(distribution_id, statistic)
112
+ statistic.each do |metric, static|
113
+ r = cloud_watch_metric(metric, static, distribution_id)
115
114
  keys = [config[:scheme]]
116
- keys.concat [distribution_id, key, static]
115
+ keys.concat [distribution_id, metric, static]
117
116
  output(keys.join('.'), r[:datapoints].first[static.downcase]) unless r[:datapoints].first.nil?
118
117
  end
119
118
  end
120
119
 
121
- def run
122
- statistic = {
120
+ def print_metrics(distribution_id, metrics)
121
+ metrics_statistic = {
123
122
  'Requests' => 'Sum',
124
123
  'BytesDownloaded' => 'Sum',
125
124
  'BytesUploaded' => 'Sum',
@@ -128,19 +127,33 @@ class CloudFrontMetrics < Sensu::Plugin::Metric::CLI::Graphite
128
127
  '5xxErrorRate' => 'Average'
129
128
  }
130
129
 
131
- unless config[:metric].nil?
132
- statistic.select! { |key, _| key == config[:metric] }
130
+ metrics.each do |metric|
131
+ statistic = metrics_statistic.select { |key, _| key == metric }
132
+ if statistic.empty?
133
+ unknown "Invalid metric #{metric}. Possible values: #{metrics_statistic.keys.join(',')}"
134
+ end
135
+ print_statistics(distribution_id, statistic)
133
136
  end
137
+ end
134
138
 
135
- begin
136
- if config[:distribution_id].nil?
137
- distribution_list.each do |distribution|
138
- print_statistics(distribution, statistic)
139
- end
140
- else
141
- print_statistics(config[:distribution_id], statistic)
139
+ def parse_metrics(metrics)
140
+ if metrics.nil?
141
+ unknown 'No metrics provided. See usage for details'
142
+ end
143
+ metrics.split(',')
144
+ end
145
+
146
+ def run
147
+ metrics = parse_metrics(config[:metrics])
148
+
149
+ if config[:distribution_id].nil?
150
+ distribution_list(metrics).each do |distribution|
151
+ print_metrics(distribution, metrics)
142
152
  end
143
- ok
153
+ else
154
+ print_metrics(config[:distribution_id], metrics)
144
155
  end
156
+
157
+ ok
145
158
  end
146
159
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
- MAJOR = 16
4
- MINOR = 2
3
+ MAJOR = 17
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.2.0
4
+ version: 17.0.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: 2019-02-20 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -424,7 +424,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
424
424
  - !ruby/object:Gem::Version
425
425
  version: '0'
426
426
  requirements: []
427
- rubygems_version: 3.0.2
427
+ rubygems_version: 3.0.3
428
428
  signing_key:
429
429
  specification_version: 4
430
430
  summary: Sensu plugins for working with an AWS environment