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
- #bytes_used_for_cache(cache_cluster_id) ⇒ Object
- #cluster_used_space(dimensions) ⇒ Object
- #es_free_storage_space(dimensions) ⇒ Object
- #free_storage_space(db_instance_identifier) ⇒ Object
- #freeable_memory(cache_cluster_id) ⇒ 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
#bytes_used_for_cache(cache_cluster_id) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aws_instance_list/metric.rb', line 45 def bytes_used_for_cache cache_cluster_id resp=statistics( { namespace: "AWS/ElastiCache", metric_name: "BytesUsedForCache", dimensions: [ { name: "CacheClusterId", value: cache_cluster_id, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) resp.datapoints.last.maximum end |
#cluster_used_space(dimensions) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/aws_instance_list/metric.rb', line 104 def cluster_used_space dimensions resp=statistics( { namespace: "AWS/ES", metric_name: "ClusterUsedSpace", dimensions: dimensions, start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.maximum end end |
#es_free_storage_space(dimensions) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/aws_instance_list/metric.rb', line 86 def es_free_storage_space dimensions resp=statistics( { namespace: "AWS/ES", metric_name: "FreeStorageSpace", dimensions: dimensions, start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Minimum"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.minimum end end |
#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 40 41 42 43 |
# 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"] }) if resp.datapoints.empty? '-' else resp.datapoints.last.minimum / ( 1024.0 ** 3) end end |
#freeable_memory(cache_cluster_id) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/aws_instance_list/metric.rb', line 66 def freeable_memory cache_cluster_id resp=statistics( { namespace: "AWS/ElastiCache", metric_name: "FreeableMemory", dimensions: [ { name: "CacheClusterId", value: cache_cluster_id, }, ], start_time: Time.now - 600, end_time: Time.now , period: 60, statistics: ["Maximum"] }) resp.datapoints.last.maximum 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 |