Class: Metrix::Load

Inherits:
Base
  • Object
show all
Defined in:
lib/metrix/load.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #time

Instance Method Summary collapse

Methods inherited from Base

#cast_int, ignore, #ignore_metric?, ignore_metrics, inherited, known_metrics, #metrics, prefix, set_known_metrics, set_prefix, subclasses, #tagged_metrics, #tags, #unfiltered_metrics

Constructor Details

#initialize(data) ⇒ Load

Returns a new instance of Load.



8
9
10
11
# File 'lib/metrix/load.rb', line 8

def initialize(data)
  @data = data
  @time = Time.now
end

Instance Method Details

#chunksObject



37
38
39
# File 'lib/metrix/load.rb', line 37

def chunks
  @chunks ||= @data.split(" ")
end

#extract(data) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/metrix/load.rb', line 13

def extract(data)
  {
    load1: load1,
    load5: load5,
    load15: load15,
  }
end

#load1Object



33
34
35
# File 'lib/metrix/load.rb', line 33

def load1
  chunks.at(0).to_f
end

#load15Object



25
26
27
# File 'lib/metrix/load.rb', line 25

def load15
  chunks.at(2).to_f
end

#load5Object



29
30
31
# File 'lib/metrix/load.rb', line 29

def load5
  chunks.at(1).to_f
end

#prefixObject



21
22
23
# File 'lib/metrix/load.rb', line 21

def prefix
  "system.load"
end