Merge multiple RRDs over time

arantius picture arantius · Mar 22, 2012 · Viewed 7.9k times · Source

I've got an old RRD file that was only set up to track 1 year of history. I decided more history would be nice. I did rrdtool resize, and the RRD is now bigger. I've got old backups of this RRD file and I'd like to merge the old data in so that the up-to-date RRD also has the historical data.

I've tried the rrd contrib "merged-rrd.py" but it gives:

    $ python merged-rrd.py ../temperature-2010-12-06.rrd ../temperature-2011-05-24.rrd merged1.rrd
    merging old:../temperature-2010-12-06.rrd to new:../temperature-2011-05-24.rrd. creating merged rrd: merged1.rrd
    Traceback (most recent call last):
        File "merged-rrd.py", line 149, in <module>
            mergeRRD(old_path, new_path, mer_path)
        File "merged-rrd.py", line 77, in mergeRRD
            odict = getXmlDict(oxml)
        File "merged-rrd.py", line 52, in getXmlDict
            cf = line.split()[1]
    IndexError: list index out of range

Also tried "rrd_merger.pl":

    $ perl rrd_merger.pl --oldrrd=../temperature-2010-12-06.rrd --newrrd=../temperature-2011-05-24.rrd --mergedrrd=merged1.rrd
    Dumping ../temperature-2010-12-06.rrd to XML: /tmp/temperature-2010-12-06.rrd_old_8615.xml
    Dumping ../temperature-2011-05-24.rrd to XML: /tmp/temperature-2011-05-24.rrd_new_8615.xml
    Parsing ../temperature-2010-12-06.rrd XML......parsing completed
    Parsing ../temperature-2011-05-24.rrd XML...
    Last Update: 1306217100
    Start processing Round Robin DB
    Can't call method "text" on an undefined value at rrd_merger.pl line 61.
     at rrd_merger.pl line 286
     at rrd_merger.pl line 286

Is there a tool to combine or merge RRDs that works?

Answer

arantius picture arantius · Mar 23, 2012

I ended up putting together a really simple script that works well enough for my case, by examining the existing python script.

http://gist.github.com/2166343