Class: AwsInstanceList::Metric
- Inherits:
-
Object
- Object
- AwsInstanceList::Metric
- Defined in:
- lib/aws_instance_list/metric.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #free_storage_space(db_instance_identifier) ⇒ Object
-
#initialize(region: 'eu-west-1') ⇒ Metric
constructor
A new instance of Metric.
- #list(options) ⇒ Object
- #statistics(options) ⇒ Object
Constructor Details
#initialize(region: 'eu-west-1') ⇒ Metric
Returns a new instance of Metric.
9 10 11 |
# File 'lib/aws_instance_list/metric.rb', line 9 def initialize region: 'eu-west-1' @client=Aws::CloudWatch::Client.new region: region end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/aws_instance_list/metric.rb', line 7 def client @client end |
Instance Method Details
#free_storage_space(db_instance_identifier) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/aws_instance_list/metric.rb', line 21 def free_storage_space db_instance_identifier resp=statistics( { namespace: "AWS/RDS", metric_name: "FreeStorageSpace", dimensions: [ { name: "DBInstanceIdentifier", value: db_instance_identifier, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Minimum"] }) resp.datapoints.last.minimum / ( 1024.0 ** 3) end |
#list(options) ⇒ Object
17 18 19 |
# File 'lib/aws_instance_list/metric.rb', line 17 def list client.list_metrics end |
#statistics(options) ⇒ Object
13 14 15 |
# File 'lib/aws_instance_list/metric.rb', line 13 def statistics client.get_metric_statistics end |