Sha256: 94e6c686211724c092a4580fafc1d563b2398dfdfb97110f3977b3e2a05286d3

Contents?: true

Size: 1.74 KB

Versions: 6

Compression:

Stored size: 1.74 KB

Contents

module Kontena::Cli::Nodes
  class ShowCommand < Clamp::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Kontena::Cli::BytesHelper

    parameter "NODE_ID", "Node id"

    def execute
      require_api_url
      require_current_grid
      token = require_token

      node = client(token).get("grids/#{current_grid}/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 "  labels:"
      if node['labels']
        node['labels'].each{|l| puts "    - #{l}"}
      end
      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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kontena-cli-0.13.4 lib/kontena/cli/nodes/show_command.rb
kontena-cli-0.13.3 lib/kontena/cli/nodes/show_command.rb
kontena-cli-0.13.2 lib/kontena/cli/nodes/show_command.rb
kontena-cli-0.13.1 lib/kontena/cli/nodes/show_command.rb
kontena-cli-0.13.0.1 lib/kontena/cli/nodes/show_command.rb
kontena-cli-0.13.0 lib/kontena/cli/nodes/show_command.rb