Preface
This tutorial is based on rrdtool, written by Tobias Oetiker. It is written by Reinhard Scheck to help you figuring out, how to resize an existing RRA of a given rrd file. This tutorial is based on Howto RESIZE existing RRAs of existing RRDs and extends this to some kind. Hope, this one will work even for windows users.
Be warned!
BACKUP ALL YOUR RRDs!
There's a good chance, that you will destroy all of your rrd files. I'm not joking! At the time of writing, rrdtool 1.2.12 is stable. Pay attention to older rrdtool-1.2.x version as they contain a bug when resizing rrd files created by rrdtool-1.0.x (see above reference for more).
SO BACKUP ALL YOUR RRDs! And check for sufficient file space!
As always: Use this information at your own risk.
Here we go!
As an attachment to the forum entry you will find a perl script resize.pl. It is necessary, to customize the /path/to/the/rrd/binary, e.g /usr/bin/rrdtool.
Help!
Put resize.pl wherever you want. There's no need to put it into the rrd working directory. But you will need some scratch space here for all rrds to be resized (due to the way rrdtool resize works). The user that runs this script must have
- write permissions to the current directory used for scratch
- read permissions on the original rrds to be resized
- write permissions to the target directory to store the resized rrds in
Code: Select all
perl resize.pl -h
Code: Select all
resize.pl Version 0.43 - resize an existing rrd
Usage: resize.pl
-f <filemask>
-r <rra> | -s <actual row size>
-o <output dir>
-g <growth>
-i
[-d <debug>]
Requires: Getopt::Std, File::Basename, File::stat, File::Copy, File::KGlob, RRDp
Author: Reinhard Scheck
Date: 2006-01-15
Options:
-f, filemask of the source rrds
-r, rra to be changed (first rra denotes as -r 0)
-s, take only rra's with exactly that actual row size
-o, output directory for resized rrds
-g, growth (number of data points to be ADDED to those already defined)
-i, invoke rrdtool info instead of resizing
-d, debug level (0=standard, 1=function trace, 2=verbose)
-h, usage and options (this help)
-s or -r must be given. -s will override -r option
No parameter validation done. Hope you know what you're going to do!
You may want to have a look at your rrds before resizing them. Specially for the required parameter -r (denoting the rra to be resized), you will want to have a look at those rras, that are defined in the rrd in question. Example (linefeeds only for ease of reading):
Code: Select all
perl resize.pl -f "/var/www/html/cacti/rra/localhost_uptime_57.rrd" /
-r 0 /
-o /var/www/html/cacti/rra/resized/
-g 8000 /
-i
Code: Select all
-- RRDTOOL INFO localhost_uptime_57.rrd ...
ds[uptime].type = "GAUGE"
rra[0].cf = "AVERAGE"
rra[0].rows = 600
rra[1].cf = "AVERAGE"
rra[1].rows = 700
rra[2].cf = "AVERAGE"
rra[2].rows = 775
rra[3].cf = "AVERAGE"
rra[3].rows = 797
rra[4].cf = "MIN"
rra[4].rows = 600
rra[5].cf = "MIN"
rra[5].rows = 700
rra[6].cf = "MIN"
rra[6].rows = 775
rra[7].cf = "MIN"
rra[7].rows = 797
rra[8].cf = "MAX"
rra[8].rows = 600
rra[9].cf = "MAX"
rra[9].rows = 700
rra[10].cf = "MAX"
rra[10].rows = 775
rra[11].cf = "MAX"
rra[11].rows = 797
rra[12].cf = "LAST"
rra[12].rows = 600
rra[13].cf = "LAST"
rra[13].rows = 700
rra[14].cf = "LAST"
rra[14].rows = 775
rra[15].cf = "LAST"
rra[15].rows = 797
- a single data source (uptime)
- four consolidation functions (AVERAGE, MIN, MAX, LAST)
- four rra's for each of the consolidation functions
Resizing a single RRA of a single RRD
For ease of use, you may simply omit the trailing parameter -i. But pay attention to the parameter -r! In this example, only the first RRA of the consolidation function AVERAGE shall be resized. It depends on your needs, whether this will result in a correct RRD!
Code: Select all
perl resize.pl -f "/var/www/html/cacti/rra/localhost_uptime_57.rrd" /
-r 0 /
-o /var/www/html/cacti/rra/resized/
-g 8000
Code: Select all
-- RRDTOOL RESIZE localhost_uptime_57.rrd RRA (0) growing 8000.. (95328).. RRA#0.. (159328).. Done.
Resizing multiple RRA of a single RRD
Simply enter all RRAs to be resized in quotes:
Code: Select all
perl resize.pl -f "/var/www/html/cacti/rra/localhost_uptime_57.rrd" /
-r \u201c0 4 8 12\u201d /
-o /var/www/html/cacti/rra/resized/
-g 8000
Code: Select all
-- RRDTOOL RESIZE localhost_uptime_57.rrd RRA (0 4 8 12) growing 8000.. (95328).. RRA#0#4#8#12.. (351328).. Done.
Please enter all RRAs to be resized in quotes and partly qualify alll RRDs:
Code: Select all
perl resize.pl -f "/var/www/html/cacti/rra/*_uptime_*.rrd" /
-r \u201c0 4 8 12\u201d /
-o /var/www/html/cacti/rra/resized/
-g 8000
Code: Select all
-- RRDTOOL RESIZE router_uptime_59.rrd RRA (0 4 8 12) growing 8000.. (95328).. RRA#0#4#8#12.. (351328).. Done.
-- RRDTOOL RESIZE gandalf_uptime_58.rrd RRA (0 4 8 12) growing 8000.. (95328).. RRA#0#4#8#12.. (351328).. Done.
-- RRDTOOL RESIZE localhost_uptime_57.rrd RRA (0 4 8 12) growing 8000.. (95328).. RRA#0#4#8#12.. (351328).. Done.
This is a new feature of this version. Use the parameter -s to specify the rowsize of the rra's you want to change. This parameter overrides the -r parameter, cause all relevant rra's will be calculated from the current rrd definition. This is useful if you're working on a list of files with different rrd structure (e.g. different Data Templates)
Code: Select all
perl resize.pl -g 8000 -f "/var/www/html/workspace/branch/rra/gandalf*.rrd" /
-s 600
-o /var/www/html/cacti/rra/resized/
-g 8000
Code: Select all
... removed ...
-- RRDTOOL RESIZE gandalf_cpu_system_9.rrd RRA (0 4 ) growing 8000..47836.. RRA#0#4..175840.. Done.
-- RRDTOOL RESIZE gandalf_cpu_user_10.rrd RRA (0 4 ) growing 8000..47836.. RRA#0#4..175840.. Done.
-- RRDTOOL RESIZE gandalf_errors_in_18.rrd RRA (0 4 ) growing 8000..188308.. RRA#0#4..700312.. Done.
... removed ...
-- RRDTOOL RESIZE gandalf_unicast_in_20.rrd RRA (0 4 ) growing 8000..94660.. RRA#0#4..350664.. Done.
... removed ...
-- RRDTOOL RESIZE gandalf_uptime_58.rrd RRA (0 4 8 12 ) growing 8000..95328.. RRA#0#4#8#12..351328.. Done.
-- RRDTOOL RESIZE gandalf_users_89.rrd RRA (0 4 8 12 ) growing 8000..95328.. RRA#0#4#8#12..351328.. Done.
user time: 0.34 system time: 1.93 real time: 7.16
Code: Select all
perl resize.pl -g 8000 -f "/var/www/html/workspace/branch/rra/gandalf*.rrd" -s 601 -o new-resized
user time: 0.01 system time: 0.02 real time: 0.23
Be warned!
You may even enter -o to resolve to the current RRD directory. This will result in overwriting your existing RRDs. YOU DON'T WANT TO DO THAT. Always look at the output after resizing. Try to generate graphs from them. Verify, that everything runs fine.
BACKUP YOUR ORIGINAL RRDs.
I appreciate any feedback to improve this document.
Reinhard Scheck aka lvm
Edit (Jan, 21th 2006): As I noticed recently, the module File::KGlob isn't really necessary. So if you get trouble with installing this really old module, simply delete this one. I checked this with some 1000 rrds without any problem