Search code examples
rrdtool

How is rrdtool PDP value calculated?


When I create a RRD database and update it with a GAUGE value 100, then value of the PDP value is set to 26.877900000. When I create a RRD database roughly a second later, then PDP value is 17.477500000:

usr@PC:~$ rm foo.rrd; rrdtool create foo.rrd --start 'N' --step '300' 'DS:RTT:GAUGE:600:0:1000000' 'RRA:AVERAGE:0.5:1:1440'; rrdtool update foo.rrd N:100; rrdtool dump foo.rrd | grep --color -E '<value>[0-9]+|<unknown_sec>|<lastupdate>'
        <lastupdate>1551973741</lastupdate> <!-- 2019-03-07 17:49:01 EET -->
                <value>2.6877900000e+01</value>
                <unknown_sec> 241 </unknown_sec>
usr@PC:~$ rm foo.rrd; rrdtool create foo.rrd --start 'N' --step '300' 'DS:RTT:GAUGE:600:0:1000000' 'RRA:AVERAGE:0.5:1:1440'; rrdtool update foo.rrd N:100; rrdtool dump foo.rrd | grep --color -E '<value>[0-9]+|<unknown_sec>|<lastupdate>'
        <lastupdate>1551973742</lastupdate> <!-- 2019-03-07 17:49:02 EET -->
                <value>1.7477500000e+01</value>
                <unknown_sec> 242 </unknown_sec>
usr@PC:~$ 

How is this PDP value calculated? My guess is that first time the rrdtool update foo.rrd N:100 happened 268.779ms later than rrdtool create. And second time the rrdtool update foo.rrd N:100 happened 174.775ms later than rrdtool create. Am I correct?


Solution

  • value contains rate*seconds which occurred up to the last run.

    Dump implementation here: rrd_dump.c

                CB_FMTS("\t\t<value>%0.10e</value>\n",
                    rrd.pdp_prep[i].scratch[PDP_val].u_val);
    

    Description of pdp_prep[].scratch[PDP_val].u_val you can find here: rrd_update.c#L1689

        /* in pdp_prep[].scratch[PDP_val].u_val we have collected
           rate*seconds which occurred up to the last run.