bin/check-dynamodb-capacity.rb in sensu-plugins-aws-0.0.4 vs bin/check-dynamodb-capacity.rb in sensu-plugins-aws-1.0.0
- old
+ new
@@ -10,12 +10,11 @@
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
-# gem: aws-sdk
-# gem: time
+# gem: aws-sdk-v1
# gem: sensu-plugin
#
# USAGE:
# Warning if any table's consumed read/write capacity is over 80%, critical if over 90%
# check-dynamodb-capacity --warning-over 80 --critical-over 90
@@ -34,24 +33,27 @@
require 'sensu-plugin/check/cli'
require 'aws-sdk-v1'
require 'time'
class CheckDynamoDB < Sensu::Plugin::Check::CLI
- option :access_key_id,
- short: '-k N',
- long: '--access-key-id ID',
- description: 'AWS access key ID'
+ option :aws_access_key,
+ short: '-a AWS_ACCESS_KEY',
+ long: '--aws-access-key AWS_ACCESS_KEY',
+ description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY'] or provide it as an option",
+ default: ENV['AWS_ACCESS_KEY']
- option :secret_access_key,
- short: '-s N',
- long: '--secret-access-key KEY',
- description: 'AWS secret access key'
+ option :aws_secret_access_key,
+ short: '-k AWS_SECRET_KEY',
+ long: '--aws-secret-access-key AWS_SECRET_KEY',
+ description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_KEY'] or provide it as an option",
+ default: ENV['AWS_SECRET_KEY']
- option :region,
- short: '-r R',
- long: '--region REGION',
- description: 'AWS region'
+ option :aws_region,
+ short: '-r AWS_REGION',
+ long: '--aws-region REGION',
+ description: 'AWS Region (defaults to us-east-1).',
+ default: 'us-east-1'
option :table_names,
short: '-t N',
long: '--table-names NAMES',
proc: proc { |a| a.split(/[,;]\s*/) },
@@ -93,13 +95,13 @@
proc: proc(&:to_f),
description: "Trigger a #{severity} if consumed capacity is over a percentage"
end
def aws_config
- hash = {}
- hash.update access_key_id: config[:access_key_id], secret_access_key: config[:secret_access_key] if config[:access_key_id] && config[:secret_access_key]
- hash.update region: config[:region] if config[:region]
- hash
+ { access_key_id: config[:aws_access_key],
+ secret_access_key: config[:aws_secret_access_key],
+ region: config[:aws_region]
+ }
end
def dynamo_db
@dynamo_db ||= AWS::DynamoDB.new aws_config
end