Sha256: 0b3d95c0f8ece7c4d1a5ebea9616373fa505f2654a6347960616d6976d2f8f33
Contents?: true
Size: 633 Bytes
Versions: 19
Compression:
Stored size: 633 Bytes
Contents
module Rearview class GraphiteParser ## returns an array of arrays of pairs with 2 elements timestamp and value (may be nil) def self.parse(lines) lines.strip.split("\n").map do |line| metric, startTime, endTime, interval, dataStr = /(.*),(\d+),(\d+),(\d+)\|(.*)/.match(line)[1..-1] data = dataStr.split(",") 0.upto(data.length - 1).map do |i| value = data[i] { :metric => metric, :timestamp => startTime.to_i + (interval.to_i * i), :value => !value.nil? ? value.to_f : value } end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems