Process::MetricsSourceProcessMetrics

module Metrics

Nested

Definitions

def self.duration(value)

Parse a duration string into seconds. According to the linux manual page specifications.

Implementation

def self.duration(value)
	if match = DURATION.match(value)
		days = match[:days].to_i
		hours = match[:hours].to_i
		minutes = match[:minutes].to_i
		seconds = match[:seconds].to_i
		fraction = match[:fraction].to_i
		
		return days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds + fraction / 100.0
	else
		return 0.0
	end
end

FIELDS = {...}

The fields that will be extracted from the ps command.

Implementation

FIELDS = {
	pid: ->(value){value.to_i}, # Process ID
	ppid: ->(value){value.to_i}, # Parent Process ID
	pgid: ->(value){value.to_i}, # Process Group ID
	pcpu: ->(value){value.to_f}, # Percentage CPU
	vsz: ->(value){value.to_i}, # Virtual Size (KiB)
	rss: ->(value){value.to_i}, # Resident Size (KiB)
	time: self.method(:duration), # CPU Time (seconds)
	etime: self.method(:duration), # Elapsed Time (seconds)
	command: ->(value){value}, # Command (name of the process)
}