gandalf wrote:No, sorry. No chance to change step size using rrdtool tune or stuff. Using official stuff only, it is NOT POSSIBLE to convert a 5 min absed rrd file to 1 min based.
If you don't trust me
please as at rrdtool-users mailing list
Reinhard
Guys,
I have written a script that reformats old 5 minute RRD files into 1 minute RRD files. I ran this against an infrastructure and it worked a charm. I will attach the scripts below. There is some information you need to make this work, and you need to be familiar navigating around Cacti. I'll be as verbose as I can to ease you through this.
(PS - I don't want any code monkeys telling me how sub-optimal this script is. Feel free and improve on it, but don't tell me it's "bad code", because as far as I'm aware, I'm the only one who's successfully done this -- Ever).
The script has a few parts, which should be explained here.
GetAndConvert - this is the wrapper script. This script takes one argument, which should be your INPUT_FILE described below. There are constants defined at the top of the script. This is where you tell the script important information about your environmeent like where to find the RRD files to convert, and where to dump them when they're done. Modify this to suit your needs. Also, since I built my 0.8.7 on a new machine, I used SCP to get the files from a remote host. If you're not doing this, you'll need to edit the script accordingly. (I've put a note on how to get your SCP working without entering a password for each file, if you don't know how to use Public Key Auth).
INPUT_FILE - YOU create this file. This file should be a list of all of the files you want to bring over and convert. You need to strip the .rrd from the filenames for the script to work properly (or you can fix this bug -- code monkey!). An easy way to do this in vim would be
or you could run something like this on your old rra dir
Code: Select all
ls | awk -F. '{print $1}' > INPUT_FILE
Whatever works for you.
FormatRRA - This is the guy that does all the work. This requires information from you as well to properly set the multipliers. Basically, what this script does is takes the raw XML of your RRD and reads through it until it finds it's first data block. We then adjust the step value in the data definition and we print every line
n times (depending on your multiplier - also discussed later). In simpler terms, the first block of a 5 minute graph has a line that defines STEP, which is set to 300 (seconds). We replace that with a new STEP because we want a 1 minute graph (60 seconds). And, since our step is different, we need more data points to make up for the missing space, so we take each value and print it out 5 times. We do this for every existing line until we encounter a new STEP definition, and we then adjust our multiplier accordingly. Making sense?
Misc Notes:
All of these scripts should be put into the same directory. You should run them all as the cacti user. You need to tell your 0.8.7
n installation about your new RRD formats. This can be done under Data Sources -> RRAs. I wrote a post a few months ago describing how to configure your new RRAs for optimal storage at high-granularity. That post is here:
http://forums.cacti.net/viewtopic.php?t ... c&start=15. I know it's long, but Read It! If you use the format I suggest there, you do not have to edit your multipliers. The only "drawback" to using the formats as I've defined them is, I want more granular data for longer, therefor my RRD files are bigger than the default. MBs are cheap these days.
Output:
This script will churn for a good few minutes on every RRD file, and I didn't bother writing in any MySQL injection (feel free). The output will give you the perfect text string to paste into your Data Source field. Here is your basic order of operations (this is in the README in the gzip attached):
* Create your RRD Structure as defined in my post on 1-minute polling (I'm tekbot).
* Create new Graph for existing device (This creates the datasource in the Database)
* Create input file for list of existing Graphs (.rrd files) from old cacti installation to convert (see section on INPUT_FILE in the post where you found these scripts).
* Edit the Constants at the top of GetAndConvert and FormatRRA to suit your needs.
* Setup SSH Private Key Authentication (Optional)
* Run the script (Syntax: ./GetAndConvert INPUT_FILE)
* Update Data source to point to new RRD.
* Place on Tree!
Have fun kids, and be safe!
--tekbot