Mainly for personal future reference.
Adding a DS to a bunch of RRD files is a big pain, RRD doesn’t have any sort of native mechanism for doing this. The usual procedure is exporting the RRD data to XML, creating a new rrd file with the old datastores plus your new ones, then importing the data back in from the XML.
A while back I needed to do this for a load of RRDs so I wrote a quick and dirty bash script for it. Today I had reason to add a DS again but couldn’t find my script. A bit of googling was no help either, surely other people have this problem too? I discovered Nicola Worthington’s RRD::Simple contains add_source method so a few moments in TextMate later we have:
#!/usr/bin/perl use strict; use warnings; use RRD::Simple(); my $rrd_path = "/path/to/dir/of/rrds/"; my @rrd_files = <$rrd_path/*.rrd>; my $rrd = RRD::Simple->new(); for my $file (@rrd_files) { print "Processing $file..."; $rrd->add_source($file, 'DS_name' => 'DERIVE'); print " ok.\n"; }
Pingback: Pnp4nagios, adding a datasource to a rrd file (not only for pnp4nagios) « Erralt
Hi, i would like to thank you because your post was helpul for me.
Thanks, very helpful.
Thanks! Your script enabled me to add my new “Garten”-Sensor to my Temperature-RRD ;-)
http://www.xalps.de/2009/04/30/offtopic-temperaturmessung-mit-einem-10e-eigenbau-sensor/
http://www.conzi.com/data/
Pingback: Temperaturmessung mit einem 10€ Eigenbau-Sensor « M8IN.DE
Sweet script, just what I was looking for! Thx!