diff --git a/bin/AWScloudwatchBilling.rb b/bin/AWScloudwatchBilling.rb index d58d3f5..1e0dd2a 100755 --- a/bin/AWScloudwatchBilling.rb +++ b/bin/AWScloudwatchBilling.rb @@ -40,7 +40,7 @@ endTime = Time.now.utc - options[:end_offset].to_i -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) %w( AmazonCloudFront AmazonDynamoDB AmazonEC2 AmazonRDS AmazonS3 AmazonSNS AWSDataTransfer ).each do |name| responses = cloudwatch.get_metric_statistics({ diff --git a/bin/AWScloudwatchDynamo.rb b/bin/AWScloudwatchDynamo.rb index e7b6cb6..c45eda1 100755 --- a/bin/AWScloudwatchDynamo.rb +++ b/bin/AWScloudwatchDynamo.rb @@ -81,7 +81,7 @@ ] -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) tables.each do |table| operationLevelMetrics.each do |metric| diff --git a/bin/AWScloudwatchEBS.rb b/bin/AWScloudwatchEBS.rb index 25a40e4..15c55b8 100755 --- a/bin/AWScloudwatchEBS.rb +++ b/bin/AWScloudwatchEBS.rb @@ -47,7 +47,7 @@ volumeIds << vol end else - compute = Fog::Compute.new(:provider => :aws, :aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) + compute = Fog::Compute.new($awscredential.merge({:provider => :aws})) compute.volumes.all.each do |vol| volumeIds << vol.id end @@ -106,7 +106,7 @@ } ] -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) volumeIds.each do |volume| metrics.each do |metric| @@ -137,4 +137,3 @@ end end end - diff --git a/bin/AWScloudwatchEC2.rb b/bin/AWScloudwatchEC2.rb index d23d668..7f31802 100755 --- a/bin/AWScloudwatchEC2.rb +++ b/bin/AWScloudwatchEC2.rb @@ -48,12 +48,8 @@ startTime = Time.now.utc - options[:start_offset].to_i endTime = Time.now.utc - options[:end_offset].to_i -compute = Fog::Compute.new( :provider => :aws, - :aws_access_key_id => $awsaccesskey, - :aws_secret_access_key => $awssecretkey) -cloudwatch = Fog::AWS::CloudWatch.new( - :aws_access_key_id => $awsaccesskey, - :aws_secret_access_key => $awssecretkey) +compute = Fog::Compute.new($awscredential.merge({:provider => :aws})) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) instance_list = compute.servers.all diff --git a/bin/AWScloudwatchELB.rb b/bin/AWScloudwatchELB.rb index efaf27d..31ffe56 100755 --- a/bin/AWScloudwatchELB.rb +++ b/bin/AWScloudwatchELB.rb @@ -69,7 +69,7 @@ unit = 'Count' -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey, :region => $awsregion) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential.merge({:region => $awsregion})) lbs.each do |table| metricNames.each do |metricName, statistic| @@ -110,7 +110,7 @@ unit = 'Seconds' -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) lbs.each do |table| metricNames.each do |statistic, metricName| @@ -142,4 +142,3 @@ end end end - diff --git a/bin/AWScloudwatchRDS.rb b/bin/AWScloudwatchRDS.rb index 3a7e0e5..69428cd 100755 --- a/bin/AWScloudwatchRDS.rb +++ b/bin/AWScloudwatchRDS.rb @@ -46,7 +46,7 @@ dbNames << db end else - rds = Fog::AWS::RDS.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) + rds = Fog::AWS::RDS.new($awscredential) rds.servers.all.each do |s| dbNames << s.id end @@ -71,7 +71,7 @@ } -cloudwatch = Fog::AWS::CloudWatch.new(:aws_secret_access_key => $awssecretkey, :aws_access_key_id => $awsaccesskey) +cloudwatch = Fog::AWS::CloudWatch.new($awscredential) dbNames.each do |db| metricNames.each do |metricName, unit| diff --git a/bin/AWScountEC2.rb b/bin/AWScountEC2.rb index 0b9f4a9..e5bdf1d 100755 --- a/bin/AWScountEC2.rb +++ b/bin/AWScountEC2.rb @@ -13,9 +13,7 @@ require 'rubygems' if RUBY_VERSION < "1.9" require 'fog' -compute = Fog::Compute.new( :provider => :aws, - :aws_access_key_id => $awsaccesskey, - :aws_secret_access_key => $awssecretkey) +compute = Fog::Compute.new($awscredential.merge({:provider => :aws})) instance_list = compute.servers.all instance_report = Hash.new diff --git a/conf/config.rb-sample b/conf/config.rb-sample index 2bc6a13..049c698 100755 --- a/conf/config.rb-sample +++ b/conf/config.rb-sample @@ -10,11 +10,20 @@ $newrelicaccount = '' # $newrelicapikey = '123123123123123123123' $newrelicapikey = '' -# AWS -# $awsaccesskey = 'AAAAAAAAAAAAAAAA' -$awsaccesskey = '' -# $awssecretkey = 'aaaaaaaaaaaaaaaaaaaaaaaaaa' -$awssecretkey = '' +# AWS Crendential - Using Keys +# $awscredential = { +# :aws_secret_access_key => 'aaaaaaaaaaaaaaaaaaaaaaaaaa', +# :aws_access_key_id => 'AAAAAAAAAAAAAAAA' +# } +$awscredential = { + :aws_secret_access_key => '', + :aws_access_key_id => '' +} +# AWS Crendential - Using IAM instance profile +# If using IAM profile: i) uncomment following & ii) comment "Using Keys" section above +# $awscredential = { +# :use_iam_profile => true +# } # $awsregion = 'us-east-1' $awsregion = 'us-east-1' @@ -63,7 +72,7 @@ $gmondport = 8649 ##OpenTSDB You'll need to manually tell tsdb about each top level metric you add like this: ## tsdb mkmetric newrelic -## tsdb mkmetric AWScloudwatch +## tsdb mkmetric AWScloudwatch # $opentsdbserver = '127.0.0.1' $opentsdbserver = '' $opentsdbport = 4242