class EcsCmd::Clusters
Public Class Methods
new(region)
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 6 def initialize(region) @client = Aws::ECS::Client.new(region: region) end
Public Instance Methods
cluster_names()
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 30 def cluster_names get_clusters[0] end
get_clusters()
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 10 def get_clusters @cluster_arns = @client.list_clusters end
get_container_instance_count(stats)
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 14 def get_container_instance_count(stats) stats['registered_container_instances_count'] end
get_pending_task_count(stats)
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 26 def get_pending_task_count(stats) stats['pending_tasks_count'] end
get_running_task_count(stats)
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 22 def get_running_task_count(stats) stats['running_tasks_count'] end
get_service_count(stats)
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 18 def get_service_count(stats) stats['active_services_count'] end
list_clusters()
click to toggle source
# File lib/ecs_cmd/clusters.rb, line 34 def list_clusters rows = [] cluster_names.map do |c| cluster_name = c.split('/')[1] stats = @client.describe_clusters(clusters: [cluster_name])[0][0] rows << [cluster_name, get_container_instance_count(stats), get_service_count(stats), get_running_task_count(stats), get_pending_task_count(stats)] end table = Terminal::Table.new headings: ['CLUSTER NAME', 'CONTAINER_INSTANCE_COUNT', 'SERVICES', 'RUNNING_TASKS', 'PENDING_TASKS'], rows: rows puts table end