RRDtool: updating RRA settings and keeping your collected data

When you use rrdtool, it can happen that you first create your databases, then collect a whole bunch of data and decide later you want more accuracy/longer periods.
Especially when using zenoss (the monitoring solution I mostly work with at Kangaroot), which uses very conservative RRD settings by default (i.e. 5-minute intervals for only the first 50 hours). Zenoss provides a way for you to change the way RRD's are created, but not to apply those settings to already existing RRD files, which I found out *after* I started monitoring everything ;)

rrdresize can help: it (just) adds or removes locations for rows.
In my case it was not good enough because zenoss uses a variety of resolutions (step sizes), and so if you add rows to all of them rrdtool - when graphing - will often pick a higher resolution RRA that just had rows added (and hence contain unknown values), even though you have the values, albeit at a lower resolution.

So you need a way to update all rows in the RRA's.
I found a perl tool that does just that. (I think, I didn't study all details). So, you install that in your /home/zenoss for instance and then you run the following script, which creates new rrd files with the new settings and uses the perl script to copy all data into it.

  1. #!/bin/sh
  2. # invoke me like this:
  3. # find /usr/local/zenoss/zenoss/perf/ -name '*.rrd' -exec ./newrrd.sh {} \; >> newrrd-logfile
  4.  
  5. file=$1
  6. backupdir=/home/zenoss/rrds-backup
  7. newdir=/home/zenoss/rrds-new
  8. [ -d "$backupdir" ] || mkdir -p "$backupdir" || exit 2
  9. [ -d "$newdir" ] || mkdir -p "$newdir" || exit 2
  10. [ -f "$file" ] || exit 3
  11.  
  12. echo "Processing $file .."
  13. base="`basename "$file"`"
  14. [ ! -f "$backupdir/$base" ] || mv "$backupdir/$base" "$backupdir/$base".old || exit 4
  15. cp "$file" "$backupdir/$base"
  16. cd "$newdir" && rrdtool create "$base" \
  17. --step '300' \
  18. --start '1230768000' \
  19. 'DS:ds0:GAUGE:900:U:U' \
  20. 'RRA:AVERAGE:0.5:1:122640' \
  21. 'RRA:AVERAGE:0.5:6:55536' \
  22. 'RRA:MAX:0.5:6:55536'
  23. /home/zenoss/rrdremove.pl "$backupdir/$base" "$base" | grep -v 2009 # hide some output
  24. cp "$base" "$file" || exit 5
  25. echo "Done"

Oh and btw, rrdwizard is a cool webapp when you're feeling too lazy/have forgotten how to write rrdtool commands

Trackback URL for this post:

http://dieter.plaetinck.be/trackback/79
Submitted by Dieter_be on Wed, 12/09/2009 - 16:05.

Comparing before and after

After modifying the script for my need, adding multiple ds(s), i did some comparison of the graphs of before and after.

i see the graph after is much more smoother than before and there are noticeable difference in average and max. I guess this is kind of expected ?
do you agree?

Well, the point was indeed

Well, the point was indeed to have higher resolution data, as Zenoss is very conservative (low-res after 50 hours) by default.
There shouldn't be big differences in average/max.
Although i have to add when i ran the script i noticed there were some graphs for which the data had become incorrect. But most of the graphs were fine.
Rely on your own judgement to see if it still looks correct afterwards. And make a backup. ;)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Security question, designed to stop automated spam bots