adding new datasource to an existing RRD
Asked Answered
E

3

8

I have few 100s of rrds and i want to add 5 extra datasource to all of those rrds.

  1. Is it advisable to do so
  2. Whats the best way and the fastest way to do it

-- Soln --

David OBrien replied in the mailing list

after searching the archives ( which you should have done first ) and googling I found several people using this...

with perl. Install RRD:Simple

#!/usr/local/bin/perl 

use strict; 
use RRD::Simple (); 

my $rrd = RRD::Simple->new(); 
my $rrdfile=$ARGV[0]; 
my $source=$ARGV[1]; 
my $type=$ARGV[2]; 
chomp($type); 
$rrd->add_source($rrdfile, $source => $type); 

usage:

./addSource.pl file.rrd ds GAUGE 

or whatever the type is..

Enjoy.

Electrotechnics answered 20/11, 2012 at 15:15 Comment(1)
you should really add David's solution as an answer to your own question and accept it.Buckling
C
2

use rrddump and rrdrestore.

just so:

rrdtool dump my.rrd > file.xml

./rrdAddDS.pl file.xml newDsName > new_file.xml

rrdtool restore new_file.xml my_new.rrd

you can refer from here: http://osdir.com/ml/db.rrdtool.user/2003-08/msg00115.html

and here: http://www.docum.org/drupal/sites/default/files/add_ds_to_rrd.pl_.txt

Carycaryatid answered 27/1, 2013 at 15:10 Comment(0)
D
2

If you're using PNP4Nagios (https://docs.pnp4nagios.org/pnp-0.6/start), they provide a utility script rrd_modify.pl for modifying existing RRD data files.

    $ rrd_modify.pl -h

   === rrd_modify.pl 0.01 ===
   Copyright (c) 2012 PNP4Nagios Developer Team (http://www.pnp4nagios.org)

   This script can be used to alter the number of data sources of an RRD file.

   Usage:
   rrd_modify.pl RRD_file insert|delete start_ds[,no_of_cols] [type]

   Arguments:
   RRD_file
      the location of the RRD file. It will NOT be overwritten but appended
      by ".chg"
   insert or delete
      the operation to be executed
   start_ds
      the position at which the operation starts (1..no of data sources+1)
   no_of_cols
      (an optional) number of columns which will be added/deleted
   type
      the data type (one of GAUGE, COUNTER)
                Defaults to GAUGE if not specified for insert operations
        (DERIVE, ABSOLUTE, COMPUTE have not been tested and might result in
                 errors during creation of a new RRD file)
Damask answered 11/8, 2014 at 17:28 Comment(0)
R
2

Since version 1.5 rrdtool create can "pre-fill" the data from existing file(s) with the --source option. This feature solves the problem without the need of additional scripts.

SEE ALSO: Matija Nalis' comment below.

Roana answered 28/1, 2018 at 7:39 Comment(1)
Even easier, you can use rrdtool tune my.rrd DS:ds_name:GAUGE:900:-50:100 to simply add data sources to existing .rrd file, while preserving old structure and data.Pazice

© 2022 - 2024 — McMap. All rights reserved.