How can I update data with RRDtool?

11,289

Solution 1

rrdtool does not write your input into the rrd file. It rather samples what you enter and then stores the resulting datapoints. So providing 'old data' to rrdtool update will not work in the same way, as you can not easily skip back in a sound recording to 'fix' a few bad notes.

Obviously there are ways to alter old data, the way todo this in rrdtool, is to 'dump' the rrd file to xml, modify the content and 'restore' it. Not something one would like todo on a regular basis.

Solution 2

I use following script in such situations:

#!/bin/sh
rrdtool dump "$1" | perl -ne 'BEGIN {$t=`date +%s`; chomp($t);} $a=$_; if ($a =~ /lastupdate.\d+..lastupdate/) { $a =~ s/(lastupdate.)\d+(..lastupdate)/$1$t$2/; } print $a' | rrdtool restore -f - "$1"

It's a little... freaky, but i could not find another automatic solution.

Solution 3

According to the RRD documentation, that timestamp number must increase with each update. Given your constraints, I'd modify your update routine so that if the update fails, you catch the exception and redo the update with the time field set to 'N'. That will make RRDtool use the current time as the update time.

Alternatively, if you don't want to deal with the catch-and-retry code, just modify your update code to always use 'N' as the time value -- then the update will always work.

It may be helpful to have a quick look at the documentation for the RRDtool update command.

Share:
11,289
Admin
Author by

Admin

Updated on July 06, 2022

Comments

  • Admin
    Admin almost 2 years

    I am using RRDtool for storing data for displaying graphs. I update the RRD by RRDs::update and this fails when trying to rewrite the information, means update data for a time in the past (e.g. someone moved the system timer back). The error I get is:

    ERROR: Cannot update /opt/dashboard/rrd/Disk/192.168.120.168_disk_1.rrd with 
    '1228032301:24:24' illegal attempt to update using time 1228032301 when last 
    update time is 1228050001 (minimum one second step)
    

    I want to always allow the rewrite, how can I do this?