Cacti (home)ForumsDocumentation

Differences

This shows you the differences between two versions of the page.

manual:100:8_rrdtool.04_resize [2019/10/29 15:16] (current)
Line 1: Line 1:
 +===== Resize RRD Files =====
 +
 +**Note:** Find an easy way to resize RRDs without using the command line at [[http://www.thetoolsmith.com/rrd_editor_index.php|The Toolsmith]]. There's a free and a commercial version. I did not use any of them until now.
 +I hope, the informations given below are at least helpful to understand rrdtool operation.
 +
 +**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.
 +
 +At the bottom of this page, please find a perl script **resize.pl**. It is necessary, to customize the **/path/to/the/rrd/binary**, e.g /usr/bin/rrdtool.
 +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
 +The script does not care about space provided. To get help, simply type
 +<code>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!</code>
 +
 +**Dry run**
 +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>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>will result in:
 +<code>-- 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</code>
 +You may notice
 +  * a single data source (uptime)
 +  * four consolidation functions (AVERAGE, MIN, MAX, LAST)
 +  * four rra's for each of the consolidation functions
 +
 +Of course, you may also enter a partly qualified dataset name. But it makes sense to take only those rrd's, that belong to the same datasource (e.g. with the same rrd file structure).
 +
 +**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>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>
 +The output will look like:
 +<code>-- RRDTOOL RESIZE localhost_uptime_57.rrd RRA (0) growing 8000.. (95328).. RRA#0.. (159328).. Done.</code>The first parenthesis contain the file size before resizing, the second one after resizing.
 +
 +**Resizing multiple RRA of a single RRD**
 +Simply enter all RRAs to be resized in quotes:
 +<code>perl resize.pl -f "/var/www/html/cacti/rra/localhost_uptime_57.rrd" /
 +            -r "0 4 8 12" /
 +            -o /var/www/html/cacti/rra/resized/
 +            -g 8000</code>
 +to result in 
 +<code>-- RRDTOOL RESIZE localhost_uptime_57.rrd RRA (0 4 8 12) growing 8000.. (95328).. RRA#0#4#8#12.. (351328).. Done.</code>
 +
 +**Resizing multiple RRAs of multiple RRDs**
 +Please enter all RRAs to be resized in quotes and partly qualify all RRDs:
 +<code>perl resize.pl -f "/var/www/html/cacti/rra/*_uptime_*.rrd" /
 +            -r "0 4 8 12" /
 +            -o /var/www/html/cacti/rra/resized/
 +            -g 8000</code>
 +to result in
 +<code>-- 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.</code>
 +
 +**Resizing all RRAs of a given row size**
 +
 +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>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>
 +to result in
 +<code>... 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>
 +
 +Please notice the last line of output, which reports the rrdtool runtime. If **-s** is given so that no rowsize of any rra will match, the corresponding rrd file is skipped:
 +<code>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</code>
 +
 +**Something to keep in mind**
 +**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. **
 +
 +{{http://docs.cacti.net/files/resize.pl.gz|resize.pl.gz}}
  





Personal Tools