class NewRelic::Agent::UtilizationData

Constants

METADATA_VERSION

Public Instance Methods

append_aws_info(collector_hash) click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 42
def append_aws_info(collector_hash)
  return unless Agent.config[:'utilization.detect_aws']

  aws_info = AWSInfo.new

  if aws_info.loaded?
    collector_hash[:vendors] ||= {}
    collector_hash[:vendors][:aws] = aws_info.to_collector_hash
  end
end
append_docker_info(collector_hash) click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 53
def append_docker_info(collector_hash)
  return unless Agent.config[:'utilization.detect_docker']

  if docker_container_id = container_id
    collector_hash[:vendors] ||= {}
    collector_hash[:vendors][:docker] = {:id => docker_container_id}
  end
end
container_id() click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 15
def container_id
  ::NewRelic::Agent::SystemInfo.docker_container_id
end
cpu_count() click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 19
def cpu_count
  ::NewRelic::Agent::SystemInfo.clear_processor_info
  ::NewRelic::Agent::SystemInfo.num_logical_processors
end
hostname() click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 11
def hostname
  NewRelic::Agent::Hostname.get
end
ram_in_mib() click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 24
def ram_in_mib
  ::NewRelic::Agent::SystemInfo.ram_in_mib
end
to_collector_hash() click to toggle source
# File lib/new_relic/agent/utilization_data.rb, line 28
def to_collector_hash
  result = {
    :metadata_version => METADATA_VERSION,
    :logical_processors => cpu_count,
    :total_ram_mib => ram_in_mib,
    :hostname => hostname
  }

  append_aws_info(result)
  append_docker_info(result)

  result
end