Class: One2Influx::OneObject
- Inherits:
-
Object
- Object
- One2Influx::OneObject
- Defined in:
- lib/one2influx/one_object/one_object.rb
Overview
‘Abstract’ class for OpenNebula’s objects representation
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(xml, client) ⇒ OneObject
constructor
Creates mapping between ONE XML names and InfluxDB storage names.
-
#method_missing(name, *args, &block) ⇒ Object
Called in case of misconfiguration and invalid custom metric method was called.
-
#serialize_as_points ⇒ Object
Serialize OneObject instance to InfluxDB point form.
Constructor Details
#initialize(xml, client) ⇒ OneObject
Creates mapping between ONE XML names and InfluxDB storage names. Loads all tags, metrics and custom metrics from given XML.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/one2influx/one_object/one_object.rb', line 10 def initialize(xml, client) @tags ||= Hash.new @metrics ||= Hash.new @doc ||= Nokogiri::XML(xml) @client = client init_metrics init_custom_metrics end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Called in case of misconfiguration and invalid custom metric method was called
39 40 41 42 |
# File 'lib/one2influx/one_object/one_object.rb', line 39 def method_missing(name, *args, &block) $LOG.error "Invalid method '#{name}' was called from #{self.class}! " #+ # "Stacktrace: #{e.backtrace}" end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/one2influx/one_object/one_object.rb', line 4 def doc @doc end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
4 5 6 |
# File 'lib/one2influx/one_object/one_object.rb', line 4 def metrics @metrics end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/one2influx/one_object/one_object.rb', line 4 def @tags end |
Instance Method Details
#serialize_as_points ⇒ Object
Serialize OneObject instance to InfluxDB point form
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/one2influx/one_object/one_object.rb', line 22 def serialize_as_points points = [] @metrics.each do |metric_name, metric_value| points << { :name => metric_name, :tags => @tags, :fields => { :value => metric_value.to_f } } end return points end |