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, #metrics, #tags, #unfiltered_metrics

Constructor Details

#initialize(data) ⇒ Load

Returns a new instance of Load.



5
6
7
8
# File 'lib/metrix/load.rb', line 5

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

Instance Method Details

#chunksObject



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

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

#extract(data) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/metrix/load.rb', line 10

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

#load1Object



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

def load1
  chunks.at(0).to_f
end

#load15Object



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

def load15
  chunks.at(2).to_f
end

#load5Object



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

def load5
  chunks.at(1).to_f
end

#prefixObject



18
19
20
# File 'lib/metrix/load.rb', line 18

def prefix
  "system.load"
end