[rrd-users] RRDs Coding Question - Dynamic Multiple RRD Data Sources

Simon Hobson linux at thehobsons.co.uk
Mon Sep 24 21:30:33 CEST 2012


Wesley Wyche wrote:

>How do you transform this into multiple dynamic input databases.  I realize
>you could simply add 4 more DEFs for each new DB etc (as well as the changes
>to the CDEFs), but that would be hardcoding the 4.

That is how RRD needs to see it.

>The problem is that there may by ANY number of databases (i.e. 1-n).

Then scripting is your friend.

You need something along the lines of :
counter=1
while counter < N
do
   echo "DEF:usrdat${counter}=/my/path/cpu${counter}.rrd:cpuusr:AVERAGE,"
   echo "DEF:nicdat${counter}=/my/path/cpu${counter}.rrd:cpunic:AVERAGE,"
   echo "DEF:sysdat${counter}=/my/path/cpu${counter}.rrd:cpusys:AVERAGE,"
   echo "DEF:idldat${counter}=/my/path/cpu${counter}.rrd:cpuidl:AVERAGE,"
   counter = ${counter} + 1
done

it gets a bit "interesting" doing this in shell (bash) script, should 
be somewhat easier in Perl (if you speak Perl).

Of course, it gets even more interesting when you get to graphing it. 
If (as is likely) you want to stack them all, then you need to do the 
first one one way, then 2-N differently (with ::STACK), and at some 
point the Nth one won't want some trailing "," or something like that.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the rrd-users mailing list