rrd-ffi icon indicating copy to clipboard operation
rrd-ffi copied to clipboard

RRD::Base#fetch returns different values in the "time" column than 'rrdtool fetch'

Open dgutov opened this issue 11 years ago • 1 comments

Take this file:

require 'rrd'

rrd = RRD::Base.new("test.rrd")

time = Time.now.to_i / 300 * 300

rrd.create!(start: time, step: 5.minutes) do
  datasource "foo", type: :gauge, heartbeat: 10.minutes, min: 0.0, max: 1000000000.0
  archive :max, every: 5.minutes, during: (5*115200).minutes
end

rrd.update(time, 500)
rrd.update(time + 300, 600)
rrd.update(time + 600, 700)

puts "#{time} to #{time + 600}"

rrd.fetch!(:max, start: time, end: time + 600).each do |row|
  puts row.join("\t")
end

Compare its output with the command-line tool:

$ ruby test.rb
1392837600 to 1392838200
time    foo
1392837600  600.0
1392837900  700.0
1392838200  NaN
$ rrdtool fetch test.rrd MAX -s 1392837600 -e 1392838200
                            foo

1392837900: 6,0000000000e+02
1392838200: 7,0000000000e+02
1392838500: -nan

All time values returned by #fetch are smaller by the value of step.

dgutov avatar Feb 19 '14 19:02 dgutov

Have the same, all values are shifted by one.

hachpai avatar Dec 08 '15 17:12 hachpai