Add alternative method to process monitoring data

This commit is contained in:
Carlos Martín committed 2013-04-10 19:33:30 +02:00
1 parent 3b5c8f00b3
commit 4bf81014a5
1 file changed
+25
+25
View File
@@ -266,4 +266,29 @@ module OpenNebula
return hash
end
# Alternative method with better performance for huge number of timestamps.
# For reasonable amounts of data, the current method is quicker
=begin
def self.process_monitoring(xmldoc, root_elem, timestamp_elem, oid, xpath_expressions)
hash = {}
xpath_expressions.each { |xpath|
hash[xpath] = []
}
xmldoc.each("#{root_elem}[ID=#{oid}]") do |elem|
timestamp = elem[timestamp_elem]
xpath_expressions.each { |xpath|
xpath_value = elem[xpath]
hash[xpath] << [timestamp, xpath_value] if !xpath_value.nil?
}
end
return hash
end
=end
end