Code

The tcl binding supports tcl < 8.5, too.
[pkg-rrdtool.git] / doc / rrdgraph_rpn.html
index ef20291cda955eb90a863b4ff63a7e75105696fb..35097c81201b2fdd77a6d145d082d61cd97a67a3 100644 (file)
@@ -9,8 +9,10 @@
 
 <body style="background-color: white">
 
-<p><a name="__index__"></a></p>
+
 <!-- INDEX BEGIN -->
+<div name="index">
+<p><a name="__index__"></a></p>
 <!--
 
 <ul>
        <li><a href="#see_also">SEE ALSO</a></li>
        <li><a href="#author">AUTHOR</a></li>
 </ul>
+
 -->
+
+
+</div>
 <!-- INDEX END -->
 
 <p>
@@ -40,7 +46,8 @@
 <hr />
 <h1><a name="description">DESCRIPTION</a></h1>
 <p>If you have ever used a traditional HP calculator you already know
-<strong>RPN</strong>. The idea behind <strong>RPN</strong> is that you have a stack and push
+<strong>RPN</strong> (Reverse Polish Notation).
+The idea behind <strong>RPN</strong> is that you have a stack and push
 your data onto this stack. Whenever you execute an operation, it
 takes as many elements from the stack as needed. Pushing is done
 implicitly, so whenever you specify a number or a variable, it gets
@@ -52,7 +59,7 @@ data point on the graph. <strong>VDEF</strong> instructions work on an entire da
 one run. Note, that currently <strong>VDEF</strong> instructions only support a limited
 list of functions.</p>
 <p>Example: <code>VDEF:maximum=mydata,MAXIMUM</code></p>
-<p>This will set variable ``maximum'' which you now can use in the rest
+<p>This will set variable &quot;maximum&quot; which you now can use in the rest
 of your RRD script.</p>
 <p>Example: <code>CDEF:mydatabits=mydata,8,*</code></p>
 <p>This means:  push variable <em>mydata</em>, push the number 8, execute
@@ -70,13 +77,14 @@ would do <code>a = b, 3, +, 5, *</code> without the need for parentheses.</p>
 <hr />
 <h1><a name="operators">OPERATORS</a></h1>
 <dl>
-<dt><strong><a name="item_boolean_operators">Boolean operators</a></strong></dt>
+<dt><strong><a name="boolean_operators" class="item">Boolean operators</a></strong></dt>
 
 <dd>
 <p><strong>LT, LE, GT, GE, EQ, NE</strong></p>
 <p>Pop two elements from the stack, compare them for the selected condition
 and return 1 for true or 0 for false. Comparing an <em>unknown</em> or an
-<em>infinite</em> value will always result in 0 (false).</p>
+<em>infinite</em> value will result in <em>unknown</em> returned ... which will also be
+treated as false by the <strong>IF</strong> call.</p>
 <p><strong>UN, ISINF</strong></p>
 <p>Pop one element from the stack, compare this to <em>unknown</em> respectively
 to <em>positive or negative infinity</em>. Returns 1 for true or 0 for false.</p>
@@ -88,7 +96,7 @@ mean that any value other than 0 is considered to be true.</p>
 <p>Example: <code>A,B,C,IF</code> should be read as <code>if (A) then (B) else (C)</code></p>
 <p></p>
 </dd>
-<dt><strong><a name="item_comparing_values">Comparing values</a></strong></dt>
+<dt><strong><a name="comparing_values" class="item">Comparing values</a></strong></dt>
 
 <dd>
 <p><strong>MIN, MAX</strong></p>
@@ -108,7 +116,7 @@ will always return an <em>unknown</em></p>
 alpha is lower than 0 or if it is higher than 100.</p>
 <p></p>
 </dd>
-<dt><strong><a name="item_arithmetics">Arithmetics</a></strong></dt>
+<dt><strong><a name="arithmetics" class="item">Arithmetics</a></strong></dt>
 
 <dd>
 <p><strong>+, -, *, /, %</strong></p>
@@ -136,7 +144,7 @@ components into an angle in degrees.</p>
 <p><strong>ABS</strong></p>
 <p>Take the absolute value.</p>
 </dd>
-<dt><strong><a name="item_set_operations">Set Operations</a></strong></dt>
+<dt><strong><a name="set_operations" class="item">Set Operations</a></strong></dt>
 
 <dd>
 <p><strong>SORT, REV</strong></p>
@@ -151,7 +159,7 @@ largest.</p>
 average, ignoring all UNKNOWN values in the process.</p>
 <p>Example: <code>CDEF:x=a,b,c,d,4,AVG</code></p>
 <p><strong>TREND, TRENDNAN</strong></p>
-<p>Create a ``sliding window'' average of another data series.</p>
+<p>Create a &quot;sliding window&quot; average of another data series.</p>
 <p>Usage:
 CDEF:smoothed=x,1800,TREND</p>
 <p>This will create a half-hour (1800 second) sliding window average of x.  The
@@ -173,8 +181,69 @@ average is essentially computed as shown here:</p>
 source value is NAN the complete sliding window is affected. The TRENDNAN 
 operation ignores all NAN-values in a sliding window and computes the 
 average of the remaining values.</p>
+<p><strong>PREDICT, PREDICTSIGMA</strong></p>
+<p>Create a &quot;sliding window&quot; average/sigma of another data series, that also
+shifts the data series by given amounts of of time as well</p>
+<p>Usage - explicit stating shifts:
+CDEF:predict=&lt;shift n&gt;,...,&lt;shift 1&gt;,n,&lt;window&gt;,x,PREDICT
+CDEF:sigma=&lt;shift n&gt;,...,&lt;shift 1&gt;,n,&lt;window&gt;,x,PREDICTSIGMA</p>
+<p>Usage - shifts defined as a base shift and a number of time this is applied
+CDEF:predict=&lt;shift multiplier&gt;,-n,&lt;window&gt;,x,PREDICT
+CDEF:sigma=&lt;shift multiplier&gt;,-n,&lt;window&gt;,x,PREDICTSIGMA</p>
+<p>Example:
+CDEF:predict=172800,86400,2,1800,x,PREDICT</p>
+<p>This will create a half-hour (1800 second) sliding window average/sigma of x, that
+average is essentially computed as shown here:</p>
+<pre>
+ +---!---!---!---!---!---!---!---!---!---!---!---!---!---!---!---!---!---&gt;
+                                                                     now
+                                                  shift 1        t0
+                                         &lt;-----------------------&gt;
+                               window
+                         &lt;---------------&gt;
+                                       shift 2
+                 &lt;-----------------------------------------------&gt;
+       window
+ &lt;---------------&gt;
+                                                      shift 1        t1
+                                             &lt;-----------------------&gt;
+                                   window
+                             &lt;---------------&gt;
+                                            shift 2
+                     &lt;-----------------------------------------------&gt;
+           window
+     &lt;---------------&gt;</pre>
+<pre>
+ Value at sample (t0) will be the average between (t0-shift1-window) and (t0-shift1)
+                                      and between (t0-shift2-window) and (t0-shift2)
+ Value at sample (t1) will be the average between (t1-shift1-window) and (t1-shift1)
+                                      and between (t1-shift2-window) and (t1-shift2)</pre>
+<p>The function is by design NAN-safe. 
+This also allows for extrapolation into the future (say a few days)
+- you may need to define the data series whit the optional start= parameter, so that 
+the source data series has enough data to provide prediction also at the beginning of a graph...</p>
+<p>Here an example, that will create a 10 day graph that also shows the 
+prediction 3 days into the future with its uncertainty value (as defined by avg+-4*sigma)
+This also shows if the prediction is exceeded at a certain point.</p>
+<p>rrdtool graph image.png --imgformat=PNG \
+ --start=-7days --end=+3days --width=1000 --height=200 --alt-autoscale-max \
+ DEF:value=value.rrd:value:AVERAGE:start=-14days \
+ LINE1:value#ff0000:value \
+ CDEF:predict=86400,-7,1800,value,PREDICT \
+ CDEF:sigma=86400,-7,1800,value,PREDICTSIGMA \
+ CDEF:upper=predict,sigma,3,*,+ \
+ CDEF:lower=predict,sigma,3,*,- \
+ LINE1:predict#00ff00:prediction \
+ LINE1:upper#0000ff:upper\ certainty\ limit \
+ LINE1:lower#0000ff:lower\ certainty\ limit \
+ CDEF:exceeds=value,UN,0,value,lower,upper,LIMIT,UN,IF \
+ TICK:exceeds#aa000080:1</p>
+<p>Note: Experience has shown that a factor between 3 and 5 to scale sigma is a good 
+discriminator to detect abnormal behavior. This obviously depends also on the type 
+of data and how &quot;noisy&quot; the data series is.</p>
+<p>This prediction can only be used for short term extrapolations - say a few days into the future-</p>
 </dd>
-<dt><strong><a name="item_special_values">Special values</a></strong></dt>
+<dt><strong><a name="special_values" class="item">Special values</a></strong></dt>
 
 <dd>
 <p><strong>UNKN</strong></p>
@@ -199,7 +268,7 @@ number 2 if it is the second, and so on. This special value allows
 you to make calculations based on the position of the value within
 the data set. This function cannot be used in <strong>VDEF</strong> instructions.</p>
 </dd>
-<dt><strong><a name="item_time">Time</a></strong></dt>
+<dt><strong><a name="time" class="item">Time</a></strong></dt>
 
 <dd>
 <p>Time inside RRDtool is measured in seconds since the epoch. The
@@ -214,7 +283,7 @@ valid at that time including daylight saving time if your OS supports
 it, and pushes the result on the stack.  There is an elaborate example
 in the examples section below on how to use this.</p>
 </dd>
-<dt><strong><a name="item_processing_the_stack_directly">Processing the stack directly</a></strong></dt>
+<dt><strong><a name="processing_the_stack_directly" class="item">Processing the stack directly</a></strong></dt>
 
 <dd>
 <p><strong>DUP, POP, EXC</strong></p>
@@ -229,51 +298,52 @@ top elements.</p>
 <h1><a name="variables">VARIABLES</a></h1>
 <p>These operators work only on <strong>VDEF</strong> statements. Note that currently ONLY these work for <strong>VDEF</strong>.</p>
 <dl>
-<dt><strong><a name="item_maximum_2c_minimum_2c_average">MAXIMUM, MINIMUM, AVERAGE</a></strong></dt>
+<dt><strong><a name="maximum_minimum_average" class="item">MAXIMUM, MINIMUM, AVERAGE</a></strong></dt>
 
 <dd>
 <p>Return the corresponding value, MAXIMUM and MINIMUM also return
 the first occurrence of that value in the time component.</p>
 <p>Example: <code>VDEF:avg=mydata,AVERAGE</code></p>
 </dd>
-<dt><strong><a name="item_stdev">STDEV</a></strong></dt>
+<dt><strong><a name="stdev" class="item">STDEV</a></strong></dt>
 
 <dd>
 <p>Returns the standard deviation of the values.</p>
 <p>Example: <code>VDEF:stdev=mydata,STDEV</code></p>
 </dd>
-<dt><strong><a name="item_last_2c_first">LAST, FIRST</a></strong></dt>
+<dt><strong><a name="last_first" class="item">LAST, FIRST</a></strong></dt>
 
 <dd>
-<p>Return the last/first value including its time.  The time for
-FIRST is actually the start of the corresponding interval, whereas
-LAST returns the end of the corresponding interval.</p>
+<p>Return the last/first non-nan or infinite value for the selected data
+stream, including its timestamp.</p>
 <p>Example: <code>VDEF:first=mydata,FIRST</code></p>
 </dd>
-<dt><strong><a name="item_total">TOTAL</a></strong></dt>
+<dt><strong><a name="total" class="item">TOTAL</a></strong></dt>
 
 <dd>
 <p>Returns the rate from each defined time slot multiplied with the
-step size.  This can, for instance, return total bytes transfered
+step size.  This can, for instance, return total bytes transferred
 when you have logged bytes per second. The time component returns
 the number of seconds.</p>
 <p>Example: <code>VDEF:total=mydata,TOTAL</code></p>
 </dd>
-<dt><strong><a name="item_percent">PERCENT</a></strong></dt>
+<dt><strong><a name="percent_percentnan" class="item">PERCENT, PERCENTNAN</a></strong></dt>
 
 <dd>
 <p>This should follow a <strong>DEF</strong> or <strong>CDEF</strong> <em>vname</em>. The <em>vname</em> is popped,
 another number is popped which is a certain percentage (0..100). The
 data set is then sorted and the value returned is chosen such that
 <em>percentage</em> percent of the values is lower or equal than the result.
+For PERCENTNAN <em>Unknown</em> values are ignored, but for PERCENT
 <em>Unknown</em> values are considered lower than any finite number for this
 purpose so if this operator returns an <em>unknown</em> you have quite a lot
 of them in your data.  <strong>Inf</strong>inite numbers are lesser, or more, than the
 finite numbers and are always more than the <em>Unknown</em> numbers.
 (NaN &lt; -INF &lt; finite values &lt; INF)</p>
-<p>Example: <code>VDEF:perc95=mydata,95,PERCENT</code></p>
+<p>Example: <code>VDEF:perc95=mydata,95,PERCENT</code>
+         <code>VDEF:percnan95=mydata,95,PERCENTNAN</code></p>
 </dd>
-<dt><strong><a name="item_lslslope_2c_lslint_2c_lslcorrel">LSLSLOPE, LSLINT, LSLCORREL</a></strong></dt>
+<dt><strong><a name="lslslope_lslint_lslcorrel" class="item">LSLSLOPE, LSLINT, LSLCORREL</a></strong></dt>
 
 <dd>
 <p>Return the parameters for a <strong>L</strong>east <strong>S</strong>quares <strong>L</strong>ine <em>(y = mx +b)</em> 
@@ -300,7 +370,8 @@ and represents the quality of fit for the approximation.</p>
 <hr />
 <h1><a name="author">AUTHOR</a></h1>
 <p>Program by Tobias Oetiker &lt;<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>&gt;</p>
-<p>This manual page by Alex van den Bogaerdt &lt;<a href="mailto:alex@ergens.op.het.net">alex@ergens.op.het.net</a>&gt;</p>
+<p>This manual page by Alex van den Bogaerdt &lt;<a href="mailto:alex@vandenbogaerdt.nl">alex@vandenbogaerdt.nl</a>&gt;
+with corrections and/or additions by several people</p>
 
 </body>