Sha256: d3d6c381b0f1721a9e333212e7b7ec32646b420965e512a9525ec762ea9ab9f3

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/aws_info'

module NewRelic
  module Agent
    class UtilizationData
      METADATA_VERSION = 1

      def hostname
        NewRelic::Agent::Hostname.get
      end

      def container_id
        ::NewRelic::Agent::SystemInfo.docker_container_id
      end

      def cpu_count
        ::NewRelic::Agent::SystemInfo.clear_processor_info
        ::NewRelic::Agent::SystemInfo.num_logical_processors
      end

      def ram_in_mib
        ::NewRelic::Agent::SystemInfo.ram_in_mib
      end

      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

      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

      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
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/utilization_data.rb
newrelic_rpm-3.12.1.298 lib/new_relic/agent/utilization_data.rb