Process::MetricsSourceProcessMetricsHostMemoryLinux

module Linux

Linux host memory: tries cgroup v2, then cgroup v1, then /proc/meminfo.

Nested

Definitions

def self.capture(cgroup_root: DEFAULT_CGROUP_ROOT)

Capture host memory from the available Linux interface.

Signature

parameter cgroup_root String

The root of the cgroup filesystem.

returns Host::Memory | Nil

The captured host memory, if available.

Implementation

def self.capture(cgroup_root: DEFAULT_CGROUP_ROOT)
	if Memory::Linux::CgroupV2.supported?(cgroup_root)
		if capture = Memory::Linux::CgroupV2.new(cgroup_root: cgroup_root).capture
			return capture
		end
	end
	
	if Memory::Linux::CgroupV1.supported?(cgroup_root)
		if capture = Memory::Linux::CgroupV1.new(cgroup_root: cgroup_root).capture
			return capture
		end
	end
	
	return Memory::Linux::Meminfo.new.capture if Memory::Linux::Meminfo.supported?
end