1 RRDGRAPH_RPN(1) rrdtool RRDGRAPH_RPN(1)
6 rrdgraph_rpn - About RPN Math in rrdtool graph
9 _\bR_\bP_\bN _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn:=_\bv_\bn_\ba_\bm_\be|_\bo_\bp_\be_\br_\ba_\bt_\bo_\br|_\bv_\ba_\bl_\bu_\be[,_\bR_\bP_\bN _\be_\bx_\bp_\br_\be_\bs_\bs_\bi_\bo_\bn]
14 this stack. Whenever you execute an operation, it takes as many ele-
15 ments from the stack as needed. Pushing is done implicitly, so whenever
16 you specify a number or a variable, it gets pushed onto the stack auto-
17 matically.
19 At the end of the calculation there should be one and only one value
20 left on the stack. This is the outcome of the function and this is
24 support a limited list of functions.
26 Example: "VDEF:maximum=mydata,MAXIMUM"
28 This will set variable "maximum" which you now can use in the rest of
29 your RRD script.
31 Example: "CDEF:mydatabits=mydata,8,*"
34 ator _\b*. The operator needs two elements and uses those to return one
36 guessed, this instruction means nothing more than _\bm_\by_\bd_\ba_\bt_\ba_\bb_\bi_\bt_\bs _\b= _\bm_\by_\bd_\ba_\bt_\ba _\b*
38 which order to process the input. For expressions like "a = b + 3 * 5"
40 with parentheses you could change this order: "a = (b + 3) * 5". In
44 Boolean operators
47 Pop two elements from the stack, compare them for the selected con-
54 tively to _\bp_\bo_\bs_\bi_\bt_\bi_\bv_\be _\bo_\br _\bn_\be_\bg_\ba_\bt_\bi_\bv_\be _\bi_\bn_\bf_\bi_\bn_\bi_\bt_\by. Returns 1 for true or 0
55 for false.
59 Pops three elements from the stack. If the element popped last is
60 0 (false), the value popped first is pushed back onto the stack,
61 otherwise the value popped second is pushed back. This does,
62 indeed, mean that any value other than 0 is considered to be true.
64 Example: "A,B,C,IF" should be read as "if (A) then (B) else (C)"
66 Comparing values
69 Pops two elements from the stack and returns the smaller or larger,
76 Pops two elements from the stack and uses them to define a range.
77 Then it pops another element and if it falls inside the range, it
80 The range defined includes the two boundaries (so: a number equal
81 to one of the boundaries will be pushed back). If any of the three
82 numbers involved is either _\bu_\bn_\bk_\bn_\bo_\bw_\bn or _\bi_\bn_\bf_\bi_\bn_\bi_\bt_\be this function will
86 lower than 0 or if it is higher than 100.
88 Arithmetics
91 Add, subtract, multiply, divide, modulo
95 Sine and cosine (input in radians), log and exp (natural loga-
96 rithm), square root.
100 Arctangent (output in radians).
104 Arctangent of y,x components (output in radians). This pops one
105 element from the stack, the x (cosine) component, and then a sec-
106 ond, which is the y (sine) component. It then pushes the arctan-
107 gent of their ratio, resolving the ambiguity between quadrants.
109 Example: "CDEF:angle=Y,X,ATAN2,RAD2DEG" will convert "X,Y" compo-
110 nents into an angle in degrees.
114 Round down or up to the nearest integer.
118 Convert angle in degrees to radians, or radians to degrees.
122 Take the absolute value.
124 Set Operations
129 then sorted (or reversed) in place on the stack.
131 Example: "CDEF:x=v1,v2,v3,v4,v5,v6,6,SORT,POP,5,REV,POP,+,+,+,4,/"
132 will compute the average of the values v1 to v6 after removing the
133 smallest and largest.
137 Pop one element (_\bc_\bo_\bu_\bn_\bt) from the stack. Now pop _\bc_\bo_\bu_\bn_\bt elements and
138 build the average, ignoring all UNKNOWN values in the process.
140 Example: "CDEF:x=a,b,c,d,4,AVG"
144 Create a "sliding window" average of another data series.
146 Usage: CDEF:smoothed=x,1800,TREND
148 This will create a half-hour (1800 second) sliding window average
149 of x. The average is essentially computed as shown here:
151 +---!---!---!---!---!---!---!---!--->
152 now
153 delay t0
154 <--------------->
155 delay t1
156 <--------------->
157 delay t2
158 <--------------->
160 Value at sample (t0) will be the average between (t0-delay) and (t0)
161 Value at sample (t1) will be the average between (t1-delay) and (t1)
162 Value at sample (t2) will be the average between (t2-delay) and (t2)
164 Special values
167 Pushes an unknown value on the stack
171 Pushes a positive or negative infinite value on the stack. When
172 such a value is graphed, it appears at the top or bottom of the
173 graph, no matter what the actual value on the y-axis is.
179 allows you to do calculations across the data. This function can-
185 otherwise the result of the vname variable at the previous time
186 step. This allows you to do calculations across the data. This
191 Pushes the number 1 if this is the first value of the data set, the
192 number 2 if it is the second, and so on. This special value allows
193 you to make calculations based on the position of the value within
196 Time
197 Time inside RRDtool is measured in seconds since the epoch. The
198 epoch is defined to be "Thu Jan 1 00:00:00 UTC 1970".
202 Pushes the current time on the stack.
206 Pushes the time the currently processed value was taken at onto the
207 stack.
212 valid at that time including daylight saving time if your OS sup-
213 ports it, and pushes the result on the stack. There is an elabo-
214 rate example in the examples section below on how to use this.
216 Processing the stack directly
219 Duplicate the top element, remove the top element, exchange the two
220 top elements.
226 MAXIMUM, MINIMUM, AVERAGE
227 Return the corresponding value, MAXIMUM and MINIMUM also return the
228 first occurrence of that value in the time component.
230 Example: "VDEF:avg=mydata,AVERAGE"
232 LAST, FIRST
233 Return the last/first value including its time. The time for FIRST
234 is actually the start of the corresponding interval, whereas LAST
235 returns the end of the corresponding interval.
237 Example: "VDEF:first=mydata,FIRST"
239 TOTAL
240 Returns the rate from each defined time slot multiplied with the
241 step size. This can, for instance, return total bytes transfered
242 when you have logged bytes per second. The time component returns
243 the number of seconds.
245 Example: "VDEF:total=mydata,TOTAL"
247 PERCENT
248 This should follow a D\bDE\bEF\bF or C\bCD\bDE\bEF\bF _\bv_\bn_\ba_\bm_\be. The _\bv_\bn_\ba_\bm_\be is popped,
249 another number is popped which is a certain percentage (0..100).
250 The data set is then sorted and the value returned is chosen such
256 numbers. (NaN < -INF < finite values < INF)
258 Example: "VDEF:perc95=mydata,95,PERCENT"
260 LSLSLOPE, LSLINT, LSLCORREL
261 Return the parameters for a L\bLeast S\bSquares L\bLine _\b(_\by _\b= _\bm_\bx _\b+_\bb_\b) which
263 line related to the COUNT position of the data. LSLINT is the
265 the graph. LSLCORREL is the Correlation Coefficient (also know as
266 Pearson's Product Moment Correlation Coefficient). It will range
267 from 0 to +/-1 and represents the quality of fit for the approxima-
268 tion.
270 Example: "VDEF:slope=mydata,LSLSLOPE"
273 rrdgraph gives an overview of how r\brr\brd\bdt\bto\boo\bol\bl g\bgr\bra\bap\bph\bh works. rrdgraph_data
274 describes D\bDE\bEF\bF,C\bCD\bDE\bEF\bF and V\bVD\bDE\bEF\bF in detail. rrdgraph_rpn describes the R\bRP\bPN\bN
276 all of the graph and print functions.
278 Make sure to read rrdgraph_examples for tips&tricks.
281 Program by Tobias Oetiker <tobi@oetiker.ch>
283 This manual page by Alex van den Bogaerdt <alex@ergens.op.het.net>
287 1.2.28 2008-07-23 RRDGRAPH_RPN(1)