class AwsInstanceList::ElastiCache

Public Class Methods

new(region: 'eu-west-1') click to toggle source
Calls superclass method AwsInstanceList::Base::new
# 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

Public Instance Methods

bytes_used_for_cache(cache_cluster_id) click to toggle source
# 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: {}) click to toggle source
# 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={}) click to toggle source
# File lib/aws_instance_list/elasti_cache.rb, line 19
def descriptions options={}
  client.describe_cache_clusters(options)
end
freeable_memory(cache_cluster_id) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/aws_instance_list/elasti_cache.rb, line 15
def list_method
  :cache_clusters
end
load_cache_fields() click to toggle source
# File lib/aws_instance_list/elasti_cache.rb, line 48
def load_cache_fields
  yaml['cache']['fields']
end
maxmemory(cache_node_type) click to toggle source
# File lib/aws_instance_list/elasti_cache.rb, line 44
def maxmemory cache_node_type
  yaml['maxmemory'][cache_node_type]
end
metrics(instance) click to toggle source
# 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