Method: OpenNebula.process_monitoring

Defined in:
lib/opennebula/pool_element.rb

.process_monitoring(xmldoc, oid, xpath_expressions) ⇒ Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].

Processes the monitoring data in XML returned by OpenNebula

Parameters:

  • xmldoc (XMLElement)

    monitoring data returned by OpenNebula monitorization timestamp

  • oid (Integer)

    Id of the object to process

  • xpath_expressions (Array<String>)

    Elements to retrieve.

Returns:

  • (Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].)

    Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/opennebula/pool_element.rb', line 266

def self.process_monitoring(xmldoc, oid, xpath_expressions)
    hash = {}
    timestamps = xmldoc.retrieve_elements(
        "/MONITORING_DATA/MONITORING[ID=#{oid}]/TIMESTAMP")

    xpath_expressions.each { |xpath|
        xpath_values = xmldoc.retrieve_elements(
            "/MONITORING_DATA/MONITORING[ID=#{oid}]/#{xpath}")

        if ( xpath_values.nil? )
            hash[xpath] = []
        else
            hash[xpath] = timestamps.zip(xpath_values)
        end
    }

    return hash
end