Class: Sys::ProcTable::CgroupEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/linux/sys/proctable/cgroup_entry.rb

Overview

This represents a cgroup entry

Have a look at `man 5 proc` on a linux distribution, to get some more information about the lines and their fields in `/proc//cgroup`.

Example:

entry = CgroupEntry.new '7:devices:/init.scope'
entry.hierarchy_id  # => 7
entry.subsystems    # => ['devices']
entry.control_group # => '/init.scope'

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ CgroupEntry

Create a new cgroup entry object

This expects a string of '7:devices:/init.scope' - see `man 5 proc` for a reference.



20
21
22
23
24
25
# File 'lib/linux/sys/proctable/cgroup_entry.rb', line 20

def initialize(string)
  @string = string.chomp
  @fields = @string.split(/:/)
rescue
  @fields = []
end

Instance Method Details

#control_groupObject

control group in the hierarchy to which the process belongs



40
41
42
# File 'lib/linux/sys/proctable/cgroup_entry.rb', line 40

def control_group
  @fields[2]
end

#hierarchy_idObject

This returns the hierarchy id of the cgroup entry



28
29
30
# File 'lib/linux/sys/proctable/cgroup_entry.rb', line 28

def hierarchy_id
  @fields[0].to_i
end

#subsystemsObject

Return sets of subsystems bound to the hierarchy



33
34
35
36
37
# File 'lib/linux/sys/proctable/cgroup_entry.rb', line 33

def subsystems
  @fields[1].split(/,/)
rescue
  []
end

#to_sObject

Return the line itself



45
46
47
# File 'lib/linux/sys/proctable/cgroup_entry.rb', line 45

def to_s
  @string
end