Class: Central::Cli::Nodes::ShowCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Central::Cli::Nodes::ShowCommand
- Includes:
- BytesHelper, Common, StackOptions
- Defined in:
- lib/central/cli/nodes/show_command.rb
Constant Summary
Constants included from BytesHelper
BytesHelper::GIGABYTE, BytesHelper::KILOBYTE, BytesHelper::MEGABYTE, BytesHelper::TERABYTE
Instance Method Summary collapse
Methods included from BytesHelper
#to_gigabytes, #to_kilobytes, #to_megabytes, #to_terabytes
Methods included from StackOptions
Methods included from Common
#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename
Instance Method Details
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/central/cli/nodes/show_command.rb', line 9 def execute require_api_url require_current_stack token = require_token node = client(token).get("stacks/#{current_stack}/nodes/#{node_id}") puts "#{node['name']}:" puts " id: #{node['id']}" puts " connected: #{node['connected'] ? 'yes' : 'no'}" puts " last connect: #{node['updated_at']}" puts " last seen: #{node['last_seen_at']}" puts " public ip: #{node['public_ip']}" puts " private ip: #{node['private_ip']}" puts " overlay network: 10.81.#{node['node_number']}.0/24" puts " os: #{node['os']}" puts " driver: #{node['driver']}" puts " kernel: #{node['kernel_version']}" puts " cpus: #{node['cpus']}" puts " memory: #{node['mem_total'] / 1024 / 1024}M" puts ' labels:' node['labels'].each { |l| puts " - #{l}" } if node['labels'] puts ' stats:' puts " cpus: #{node['cpus']}" loads = node.dig('resource_usage', 'load') if loads puts " load: #{loads['1m'].round(2)} #{loads['5m'].round(2)} #{loads['15m'].round(2)}" end mem = node.dig('resource_usage', 'memory') if mem mem_used = mem['used'] - (mem['cached'] + mem['buffers']) puts " memory: #{to_gigabytes(mem_used, 2)} of #{to_gigabytes(mem['total'], 2)} GB" end if node['resource_usage']['filesystem'] puts ' filesystem:' node['resource_usage']['filesystem'].each do |filesystem| puts " - #{filesystem['name']}: #{to_gigabytes(filesystem['used'], 2)} of #{to_gigabytes(filesystem['total'], 2)} GB" end end end |