Class: LogStash::Instrument::PeriodicPoller::Cgroup::CpuStats

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/instrument/periodic_poller/cgroup.rb

Instance Method Summary collapse

Constructor Details

#initializeCpuStats

Returns a new instance of CpuStats.



162
163
164
165
166
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 162

def initialize
  @number_of_elapsed_periods = -1
  @number_of_times_throttled = -1
  @time_throttled_nanos = -1
end

Instance Method Details

#to_hashObject



178
179
180
181
182
183
184
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 178

def to_hash
  {
    :number_of_elapsed_periods => @number_of_elapsed_periods,
    :number_of_times_throttled => @number_of_times_throttled,
    :time_throttled_nanos => @time_throttled_nanos
  }
end

#update(lines) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/logstash/instrument/periodic_poller/cgroup.rb', line 167

def update(lines)
  lines.each do |line|
    fields = line.split(/\s+/)
    next unless fields.size > 1
    case fields.first
    when "nr_periods" then @number_of_elapsed_periods = fields[1].to_i
    when "nr_throttled" then @number_of_times_throttled = fields[1].to_i
    when "throttled_time" then @time_throttled_nanos = fields[1].to_i
    end
  end
end