Class: LogStash::Instrument::PeriodicPoller::Cgroup::CGroupResources
- Inherits:
-
Object
- Object
- LogStash::Instrument::PeriodicPoller::Cgroup::CGroupResources
- Defined in:
- lib/logstash/instrument/periodic_poller/cgroup.rb
Constant Summary collapse
- CONTROL_GROUP_RE =
Regexp.compile("\\d+:([^:,]+(?:,[^:,]+)?):(/.*)")
- CONTROLLER_SEPARATOR_RE =
","
Instance Method Summary collapse
Instance Method Details
#cgroup_available? ⇒ Boolean
48 49 50 51 |
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 48 def cgroup_available? # don't cache to ivar, in case the files are mounted after logstash starts?? CRITICAL_PATHS.all?{|path| ::File.exist?(path)} end |
#controller_groups ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 53 def controller_groups response = {} IO.readlines(CGROUP_FILE).each do |line| matches = CONTROL_GROUP_RE.match(line) next if matches.nil? # multiples controls, same hierarchy controllers = matches[1].split(CONTROLLER_SEPARATOR_RE) controllers.each do |controller| case controller when CONTROLLER_CPU_LABEL response[controller] = CpuResource.new(matches[2]) when CONTROLLER_CPUACCT_LABEL response[controller] = CpuAcctResource.new(matches[2]) else response[controller] = UnimplementedResource.new(controller, matches[2]) end end end response end |