Class: AwsInstanceList::ElastiCache
- Inherits:
-
Base
- Object
- Base
- AwsInstanceList::ElastiCache
show all
- Defined in:
- lib/aws_instance_list/elasti_cache.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #metric, #region
Instance Method Summary
collapse
Methods inherited from Base
#demodulize, #instances, #yaml, #yaml_default, #yaml_file
Constructor Details
#initialize(region: 'eu-west-1') ⇒ ElastiCache
Returns a new instance of ElastiCache.
7
8
9
10
11
12
13
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 7
def initialize region: 'eu-west-1'
super region: region
@client=Aws::ElastiCache::Client.new region: region
end
|
Instance Method Details
#bytes_used_for_cache(cache_cluster_id) ⇒ Object
23
24
25
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 23
def bytes_used_for_cache cache_cluster_id
metric.bytes_used_for_cache cache_cluster_id
end
|
#cache_list(options: {}, fields: nil) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 31
def cache_list options: {}, fields: nil
fields||=load_cache_fields
instances(options).map do |i|
fields.map { |f| i.send(f) } + metrics(i) << region
end
end
|
#descriptions(options = {}) ⇒ Object
19
20
21
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 19
def descriptions options={}
client.describe_cache_clusters(options)
end
|
#freeable_memory(cache_cluster_id) ⇒ Object
27
28
29
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 27
def freeable_memory cache_cluster_id
metric.freeable_memory cache_cluster_id
end
|
#group_name(i) ⇒ Object
40
41
42
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 40
def group_name i
i.cache_parameter_group.cache_parameter_group_name
end
|
#list_method ⇒ Object
15
16
17
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 15
def list_method
:cache_clusters
end
|
#load_cache_fields ⇒ Object
48
49
50
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 48
def load_cache_fields
yaml['cache']['fields']
end
|
#maxmemory(cache_node_type) ⇒ Object
44
45
46
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 44
def maxmemory cache_node_type
yaml['maxmemory'][cache_node_type]
end
|
#metrics(instance) ⇒ Object
52
53
54
55
56
|
# File 'lib/aws_instance_list/elasti_cache.rb', line 52
def metrics instance
used=bytes_used_for_cache(instance.cache_cluster_id) / 1024
total=maxmemory(instance.cache_node_type) / 1024
[total, used]
end
|