bin/metrics-s3.rb in sensu-plugins-aws-10.1.1 vs bin/metrics-s3.rb in sensu-plugins-aws-10.1.2
- old
+ new
@@ -44,19 +44,22 @@
description: 'Metric naming scheme, text to prepend to metric',
short: '-s SCHEME',
long: '--scheme SCHEME',
default: 'sensu.aws.s3.buckets'
+ def bucket_size(size_size = 'bytes'); end
+
def run
begin
s3 = Aws::S3::Client.new(aws_config)
list_buckets = s3.list_buckets
cw = Aws::CloudWatch::Client.new(aws_config)
now = Time.now
- list_buckets.buckets.each do |bucket|
+ # TODO: come back and refactor this
+ list_buckets.buckets.each do |bucket| # rubocop:disable Metrics/BlockLength)
bucket_name = bucket.name.tr('.', '_')
bucket_size_bytes = cw.get_metric_statistics(
namespace: 'AWS/S3',
metric_name: 'BucketSizeBytes',
dimensions: [
@@ -94,11 +97,10 @@
statistics: ['Average'],
unit: 'Count'
)
output "#{config[:scheme]}.#{bucket_name}.number_of_objects", number_of_objects[:datapoints][0].average, now.to_i unless number_of_objects[:datapoints][0].nil?
end
-
- rescue => e
+ rescue StandardError => e
critical "Error: exception: #{e}"
end
ok
end
end