Adding new data sources to existing RRDs

Tobi Oetiker’s RRD tool (“round-robin database”) is a very powerful and really useful tool set to store long-term monitoring data. The only feature it lacks out of the box is adding new “data sources” to an existing database. RRDtool has been around quite some time by now and comes with an ecosystem of tools. For instance, Joost Cassee has provided a Perl program in 2005 to add a new data source, which can be found in the contrib area of Tobi’s site.

That tool comes in source form but will run without further preparation on any machine with Perl support, i.e. your favorite Linux installation. It’s mostly a wrapper to the required work flow, automating the export/import steps and inserting the required nodes into the intermediate XML document.

While this comes very handy if you have only one data source to add, it quickly turns into a source of delay and manual errors when having to add many data sources. We’ve enhanced the code to take multiple new data sources and made it available here – you can use it the same way as the original, except that you have the option to name more than one new data source on the command line:

user@host:~> rrdaddsource.pl --help
usage:  rrdaddsource <original rrd file> <new rrd file> <data source> { <data source> }

Adds new data sources to an RRD database. Uses rrdtool to dump the original
database to an XML file, edits it and then restores it to the new database.

The datasource arguments have the same format as in rrdtool create:
  ds-name:DST:heartbeat:min:max
See rrdcreate(1) for more information. Note that those arguments are not checked
for validity.
user@host:~> rrdtool myoriginalcopy.rrd mynewextended.rrd test1:GAUGE:180:0:100 test2:GAUGE:180:0:100 test3:GAUGE:180:0:100
user@host:~>

As usual, this code comes without any warranty of any kind, so use it at your own risk and never forget to make a backup of the original database file, in case something goes wrong.

According to the inline comments, the tool was originally licensed under GPL. The link to the original license text seems no longer functional (the host name couldn’t be resolved), so according to the program’s age I have assumed it is under GPL V2 and will leave it that way.

This entry was posted in Linux. Bookmark the permalink.

Leave a Reply