module Datadog::Core::Environment::Cgroup
Reads information from Linux cgroups. This information is used to extract information about the current Linux container identity. @see man7.org/linux/man-pages/man7/cgroups.7.html
Constants
- Descriptor
- LINE_REGEX
Public Instance Methods
descriptors(process = 'self')
click to toggle source
# File lib/datadog/core/environment/cgroup.rb, line 25 def descriptors(process = 'self') [].tap do |descriptors| begin filepath = "/proc/#{process}/cgroup" if File.exist?(filepath) File.foreach("/proc/#{process}/cgroup") do |line| line = line.strip descriptors << parse(line) unless line.empty? end end rescue StandardError => e Datadog.logger.error("Error while parsing cgroup. Cause: #{e.message} Location: #{Array(e.backtrace).first}") end end end
parse(line)
click to toggle source
# File lib/datadog/core/environment/cgroup.rb, line 42 def parse(line) id, groups, path = line.scan(LINE_REGEX).first Descriptor.new(id, groups, path).tap do |descriptor| descriptor.controllers = groups.split(',') unless groups.nil? end end