Module: Process::Metrics

Defined in:
lib/process/metrics/memory.rb,
lib/process/metrics/command.rb,
lib/process/metrics/general.rb,
lib/process/metrics/version.rb,
lib/process/metrics/command/top.rb,
lib/process/metrics/command/summary.rb

Defined Under Namespace

Modules: Command Classes: General, Memory

Constant Summary collapse

PS =
"ps"
FIELDS =

pid: Process Identifier pmem: Percentage Memory used. pcpu: Percentage Processor used. time: The process time used (executing on CPU). vsz: Virtual Size in kilobytes rss: Resident Set Size in kilobytes etime: The process elapsed time. command: The name of the process.

{
	pid: ->(value){value.to_i},
	ppid: ->(value){value.to_i},
	pgid: ->(value){value.to_i},
	pcpu: ->(value){value.to_f},
	time: self.method(:duration),
	vsz: ->(value){value.to_i},
	rss: ->(value){value.to_i},
	etime: self.method(:duration),
	command: ->(value){value},
}
VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.duration(value) ⇒ Object

According to the linux manual page specifications.



31
32
33
34
35
# File 'lib/process/metrics/general.rb', line 31

def self.duration(value)
	if /((?<days>\d\d)\-)?((?<hours>\d\d):)?(?<minutes>\d\d):(?<seconds>\d\d)?/ =~ value
		(((days&.to_i || 0) * 24 + (hours&.to_i || 0)) * 60 + (minutes&.to_i || 0)) * 60 + seconds&.to_i
	end
end