Class: CollectdServer::DatapointBuilder::LoadAvg

Inherits:
CollectdServer::DatapointBuilder show all
Defined in:
lib/collectd_server/datapoint_builder.rb

Instance Attribute Summary

Attributes inherited from CollectdServer::DatapointBuilder

#host, #interval, #parts, #plugin, #plugin_instance, #timestamp, #type, #type_instance, #values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CollectdServer::DatapointBuilder

from_parts, inherited, #initialize, #metric_name, subclasses

Constructor Details

This class inherits a constructor from CollectdServer::DatapointBuilder

Class Method Details

.plugin_nameObject



106
107
108
# File 'lib/collectd_server/datapoint_builder.rb', line 106

def self.plugin_name
  'load'
end

Instance Method Details

#generate_datapointsObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/collectd_server/datapoint_builder.rb', line 110

def generate_datapoints
  datapoints = []
  @values.values.each_with_index do |val, i|
    instance = case i
               when 0 then "1min"
               when 1 then "5min"
               when 2 then "15min"
               end

    datapoints << Datapoint.new(metric_name([@host, "load", instance]),
                                timestamp,
                                val.value)
  end
  datapoints
end