1

Say, I was writing values to a database, then stopped doing so, and now I want to continue starting from current point in time. As far as I can see, if I fail to write something within heartbeat seconds, it stops writing to the database:

#!/usr/bin/env bash
set -eu
DIR=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")
SCRIPT=$(basename -- "$(readlink -f -- "${BASH_SOURCE[0]}")")

start=1420729200
echo start: $start $(date -d @$start)
rrdtool create "$DIR/1.rrd" \
    --start "$start" \
    --step 300 \
    DS:g:GAUGE:600:U:U \
    RRA:MAX:0.5:1:10
rrdtool update "$DIR/1.rrd" $(( start + 601 )):111
rrdtool dump "$DIR/1.rrd"

What am I doing wrong? What is heartbeat exactly? I thought it defines how many adjacent input values are used for interpolating PDP values. What am I missing?

UPD If I do update with $start timestamp value, I get:

ERROR: /home/yuri/_/1.rrd: illegal attempt to update using time 1420729200 when last update time is 1420729200 (minimum one second step)

So it works for $(( start + 1 )) to $(( start + 600 )) including both ends. I don't get errors when I do update with $(( start + >600 )).

x-yuri
  • 16,722
  • 15
  • 114
  • 161
  • so you don't get any error messages?, or something like 'stopping rrdtool because HEARTBEAT secs have passed'? If you do get status or error messages, please update your question to include the relevant portions. Good luck. – shellter Jan 08 '15 at 16:43
  • 1
    Time-series data == you will have a regular set of data 'updates'; if you need to 'start over' then re-create your RRD. If you really want to allow gaps, then add 'null values' to cover your 'hearbeat' interval. Some of the blue lines on the graphs on this page contain 'gaps' (sensor went missing); if the data is missing the RRD still gets updated with a 'null' value: http://www.ga-usa.com/weather/gradients/usa-sav-ga-attic-weather-rrd-charts-half-gradient.html; Soo, if you have a gap in your data-collection process you will need to either start over or fill-in-the-gaps.with 'null' data. – Dale_Reagan Jan 09 '15 at 02:39
  • @Dale_Reagan Your link gives me `403 Forbidden`. Also, consider making it an answer, I will most likely accept it. – x-yuri Jan 09 '15 at 04:45
  • You have the author or RRDTool (Tobi) with a definitive answer - my suggestion is a work-around; not a solution. :) – Dale_Reagan Jan 10 '15 at 03:29

1 Answers1

1

Two updates to your RRD database must not be further than HEARTBEAT seconds apart. Or rrdtool will disregard your update. It will only register the update as a new starting point, and if the next update is within HEARTBEAT seconds, the value will appear in the database:

rrdtool update "$DIR/$SCRIPT.rrd" $(( start + 601 )):111   # new starting point
rrdtool update "$DIR/$SCRIPT.rrd" $(( start + 900 )):222   # gets into database

In rrdtool 1.4.9 and newer, the last HEARBEAT seconds before your update will be considered valid data, which will work if you have a GAUGE type datasource. If your heartbeat if 500s and you provide an update after 900s, rrdtool will consider the data valid for the last 500 seconds. If the step is 300 seconds, you will end up with 2 unknown steps and one known step ... but as I said this is only in 1.4.9 and later.

Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23
  • So you're saying that `rrdtool` expects updates to be not further than `heartbeat` seconds apart? If it receives a value which is more than `heartbeat` seconds older, it ignores the value, but registers the timestamp as a new starting point. And if the next update is within `heartbeat` seconds, corresponding value will make it to the database. Right? Not sure I get the part about "valid data". Doesn't it say the same as above but in other words? – x-yuri Jan 10 '15 at 20:52
  • Could you explain it not only in words? Some shell commands or something? I'm now running `rrdtool-1.4.9`. I've got database with 500 sec `heartbeat`: `DS:g:GAUGE:500:U:U`. I make two updates: `rrdtool update "$DIR/1.rrd" $(( start + 300 )):1`, `rrdtool update "$DIR/1.rrd" $(( start + 1200 )):2`. And I've got only one value in database: `1420729500: 1.0000000000e+00`, `1420729800: NaN`, `1420730100: NaN`, `1420730400: NaN`. – x-yuri Jan 12 '15 at 07:26