views:

203

answers:

1

I don't know how to explain my problem.... but I have two RRD files:

a.rrd
b.rrd

I'm trying to sum both of the files and STACK them up in the graph. like:

my $bla = RRDs::graph "-",

    "--title","Test",
    "--imgformat=PNG",
    "--width=680",
    "--height=200",

    "DEF:Default0_=a.rrd:default:AVERAGE",
    "DEF:Real0_=a.rrd:real:AVERAGE",

    "DEF:Default1_=b.rrd:default:AVERAGE",
    "DEF:Real1_=b.rrd:real:AVERAGE",


    "CDEF:Default=Default0_,Default1_,+",        
    "CDEF:Real=Real0_,Real1_,+",


    'AREA:Default#00CF00:Default Test',
    'GPRINT:Default:MIN:Min\: %10.0lf%s',
    'GPRINT:Default:MAX:Max\: %10.0lf%s',
    'GPRINT:Default:AVERAGE:Average\: %10.0lf%s',
    'GPRINT:Default:LAST:Current\: %10.0lf%s \l',

    'STACK:Real#006699:Real Test',
    'LINE2:Real#000000',
    'GPRINT:Real:MIN:Min\: %10.0lf%s',
    'GPRINT:Real:MAX:Max\: %10.0lf%s',
    'GPRINT:Real:AVERAGE:Average\: %10.0lf%s',
    'GPRINT:Real:LAST:Current\: %10.0lf%s \l',

And my Result is:

alt text

problem: it doesn't print the values from file a.rrd, it display the graph only from the position of the b.rrd file.

instide of something like this ( only the first part will be with zeros ):

alt text

Obviously, this is because the second graph doesn't have unix timestamp when the first graph does.

so how can i fill it with zeros ? or change my graph conf ?

+1  A: 

Here is the solution to your problem :) http://oss.oetiker.ch/rrdtool/tut/cdeftutorial.en.html Take a look at the use of IF,TIME,GT and etc. functions. You can try this: CDEF:Real=TIME,sometimestamp,GT,Real0_,Real0_,UN,0,Real0_,IF,IF,TIME,sometimestamp,GT,Real1_,Real1_,UN,0,Real1_,IF,IF,+ This means: if( TIME() > sometimestamp ) return Real0_ else if (Real0_ == UN(this is the NaN value in rrd files) ) return 0 else return Real0_ Make the same thing for the Real1_ and make the sum of the two result. Hope I helped :)

Zhivko Donev