-1

If I dump an RRD to XML, then under "PDP Status" section there are three elements: <last_ds>, <value> and <unknown_sec>. For example:

            <!-- PDP Status -->
            <last_ds>90</last_ds>
            <value>4.2177496500e+03</value>
            <unknown_sec> 184 </unknown_sec>

Now as I understand, then each time I execute "rrd update", I will update Primary Data Point (PDP). Looks like whatever I put as a value for rrdtool update(for example rrdtool update test.rrd "N:abc"), then it is shown as a value for <last_ds> element. However, how is the number for <value> calculated? I mean the number 4217.7496500 in example above. Is this some kind of average? Last but not least, while I understand that <unknown_sec> shows the number of seconds when value of the DS has been unknown, then this counter seems to wrap around 280 - 295 seconds. How to explain this? I mean for example if I execute while true; do rrdtool update test.rrd "N:75"; rrdtool dump test.rrd | grep "<unknown_sec>"; sleep 1; done where 75 is lower than the lowest value allowed for this DS, then output is following:

   /* data not shown for brevity */
   <unknown_sec> 280 </unknown_sec>
   <unknown_sec> 281 </unknown_sec>
   <unknown_sec> 282 </unknown_sec>
   <unknown_sec> 0 </unknown_sec>
   <unknown_sec> 1 </unknown_sec>
   <unknown_sec> 2 </unknown_sec>
   /* data not shown for brevity */
Martin
  • 957
  • 7
  • 25
  • 38

2 Answers2

3

the PDP content of <value> is the sum of all products of input value multiplied by duration this value was valid for. In order to build the PDP, at the end of the interval, this value is divided by the duration of the interval minus the number of unknown seconds ... The number of unknown seconds resets to 0 when a new interval is started ...

Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23
0

Although the founder of RRDtool above gave the correct answer, it is not straight forward enough to understand.

The process of calculating PDP is intricate and nontrivial, and it may not be fully understood even by advanced LLMs like ChatGPT-4. This conclusion is based on my lengthy and intensive discussions with it over the half of the night...

I recommend this page to get the calculation more perceptual.

And to explain this with simple text (after nearly half night searching, reading, verifying and summarizing):

  1. Suppose a 5-second step(defined with RRD, not RRA) interval, noted as [0,5], [5,10],[10,15](the intersection is trivial)
  2. The inputs, formated as (time, value): (00:03,8), (00:06,1), (00:17,6)
  3. Now if we fetch data with 5 seconds interval(defined with RRA step) from timepoint 00:00, we can get these results: (time:00:05, value:5.2), (time:00:10, value:5), (time:00:15, value:6).

The calculation could be described as below

  • For interval [0,5]: we estimate that the value 8 span from 00:00 (begin of the universe) to 00:03, and value 1 span from 00:03 (last time we knew exact input value) to 00:06 (exact time input occured), then do math: (8*3 + 1*2)/5 = 26/5 = 5.2;
  • For interval [5,10]: likewise, do math (1*6 + 6*4)/5 = 5;
  • For interval [10,15]: value 6 inputed at 00:17 span from 00:06 covered whole interval, so the result is 6.

Some reader may find out that these exemplar input data comes from this page. However the explanation and calculation of it is inaccurate, while the result I listed above could be verified with the latest version of RRDtool.

In one word, the PDP is a weighted average of the input value, where each term is the product of the input value and its duration. This so-called duration is the time span between this input value and the last one.

Xavier Z.
  • 128
  • 10