Class: CollectdServer::CPU

Inherits:
Mapper
  • Object
show all
Defined in:
lib/collectd_server/mapper.rb

Instance Attribute Summary

Attributes inherited from Mapper

#metric_name, #timestamp, #value

Class Method Summary collapse

Methods inherited from Mapper

#initialize, #to_datapoint

Constructor Details

This class inherits a constructor from CollectdServer::Mapper

Class Method Details

.matches?(line) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/collectd_server/mapper.rb', line 64

def self.matches?(line)
  plugin_name(line) =~ /cpu-[\d+]/
end

.metric_name_from_type(collectd_type) ⇒ Object



77
78
79
80
81
82
# File 'lib/collectd_server/mapper.rb', line 77

def self.metric_name_from_type(collectd_type)
  super

  # apollo, cpu,   0,                idle
  [@host, @plugin, @plugin_instance, @type_instance].join(',')
end

.parse(line) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/collectd_server/mapper.rb', line 68

def self.parse(line)
  path, timestamp, values = parse_line(line)

  metric_name = metric_name_from_type(path)
  values.map do |val|
    self.new(metric_name, timestamp, val)
  end
end