lib/pghero/methods/system.rb in pghero-1.6.4 vs lib/pghero/methods/system.rb in pghero-1.6.5
- old
+ new
@@ -21,15 +21,21 @@
rds_stats("WriteIOPS", options)
end
def rds_stats(metric_name, options = {})
if system_stats_enabled?
+ options = {region: region}
+ if access_key_id
+ options[:access_key_id] = access_key_id
+ options[:secret_access_key] = secret_access_key
+ end
+
client =
if defined?(Aws)
- Aws::CloudWatch::Client.new(access_key_id: access_key_id, secret_access_key: secret_access_key, region: region)
+ Aws::CloudWatch::Client.new(options)
else
- AWS::CloudWatch.new(access_key_id: access_key_id, secret_access_key: secret_access_key, region: region).client
+ AWS::CloudWatch.new(options).client
end
duration = (options[:duration] || 1.hour).to_i
period = (options[:period] || 1.minute).to_i
offset = (options[:offset] || 0).to_i
@@ -56,10 +62,10 @@
{}
end
end
def system_stats_enabled?
- !!((defined?(Aws) || defined?(AWS)) && access_key_id && secret_access_key && db_instance_identifier)
+ !!((defined?(Aws) || defined?(AWS)) && db_instance_identifier)
end
def access_key_id
ENV["PGHERO_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"]
end