Class: CollectdServer::DatapointBuilder::CPU
Instance Attribute Summary
#host, #interval, #parts, #plugin, #plugin_instance, #timestamp, #type, #type_instance, #values
Class Method Summary
collapse
Instance Method Summary
collapse
from_parts, inherited, #initialize, subclasses
Class Method Details
.plugin_name ⇒ Object
71
72
73
|
# File 'lib/collectd_server/datapoint_builder.rb', line 71
def self.plugin_name
'cpu'
end
|
Instance Method Details
#generate_datapoints ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/collectd_server/datapoint_builder.rb', line 79
def generate_datapoints
current_value = @values.values.first.value
datapoints = []
unless previous_value.nil?
delta = current_value - previous_value
rate = delta.to_f / interval
datapoints = [Datapoint.new(metric_name, timestamp, rate)]
end
self.previous_value = current_value
datapoints
end
|
#metric_name ⇒ Object
75
76
77
|
# File 'lib/collectd_server/datapoint_builder.rb', line 75
def metric_name
super [@host, @plugin, @plugin_instance, @type_instance, 'jiffies/s']
end
|
#previous_value ⇒ Object
93
94
95
|
# File 'lib/collectd_server/datapoint_builder.rb', line 93
def previous_value
@previous_value ||= PREVIOUS_VALUES[metric_name]
end
|
#previous_value=(value) ⇒ Object
97
98
99
|
# File 'lib/collectd_server/datapoint_builder.rb', line 97
def previous_value=(value)
PREVIOUS_VALUES[metric_name] = value
end
|