complete rewrite of rrdgraph documentation. This also includs info
[rrdtool.git] / doc / rrdgraph-old.pod
1 =head1 NAME
2
3 rrdtool graph - Create a graph based on data from one or several RRD
4
5 =for html <div align="right"><a href="rrdgraph.pdf">PDF</a> version.</div> 
6
7 =head1 SYNOPSIS
8
9 B<rrdtool> B<graph> I<filename> 
10 S<[B<-s>|B<--start> I<seconds>]> 
11 S<[B<-e>|B<--end> I<seconds>]>
12 S<[B<-x>|B<--x-grid> I<x-axis grid and label>]>
13 S<[B<-y>|B<--y-grid> I<y-axis grid and label>]>
14 S<[B<--alt-y-grid>]>
15 S<[B<--alt-autoscale>]>
16 S<[B<--alt-autoscale-max>]>
17 S<[B<--units-exponent>]> I<value>]>
18 S<[B<-v>|B<--vertical-label> I<text>]>
19 S<[B<-w>|B<--width> I<pixels>]>
20 S<[B<-h>|B<--height> I<pixels>]> 
21 S<[B<-i>|B<--interlaced>]> 
22 S<[B<-f>|B<--imginfo> I<formatstring>]> 
23 S<[B<-a>|B<--imgformat> B<GIF>|B<PNG>]> 
24 S<[B<-z>|B<--lazy>]> 
25 S<[B<-o>|B<--logarithmic>]>
26 S<[B<-u>|B<--upper-limit> I<value>]> 
27 S<[B<-l>|B<--lower-limit> I<value>]>
28 S<[B<-g>|B<--no-legend>]>
29 S<[B<-r>|B<--rigid>]>
30 S<[B<--step> I<value>]>
31 S<[B<-b>|B<--base> I<value>]>
32 S<[B<-c>|B<--color> I<COLORTAG>B<#>I<rrggbb>]>
33 S<[B<-t>|B<--title> I<title>]>
34 S<[B<DEF:>I<vname>B<=>I<rrd>B<:>I<ds-name>B<:>I<CF>]>
35 S<[B<CDEF:>I<vname>B<=>I<rpn-expression>]>
36 S<[B<PRINT:>I<vname>B<:>I<CF>B<:>I<format>]>
37 S<[B<GPRINT:>I<vname>B<:>I<CF>B<:>I<format>]>
38 S<[B<COMMENT:>I<text>]>
39 S<[B<HRULE:>I<value>B<#>I<rrggbb>[B<:>I<legend>]]>
40 S<[B<VRULE:>I<time>B<#>I<rrggbb>[B<:>I<legend>]]>
41 S<[B<LINE>{B<1>|B<2>|B<3>}B<:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]>
42 S<[B<AREA:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]>
43 S<[B<STACK:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]>
44 S<[B<TICK:>I<vname>B<#>I<rrggbb>[B<:>I<axis-fraction>[B<:>I<legend>]]]>
45
46 =head1 DESCRIPTION
47
48 The B<graph> functions main purpose is to create graphical
49 representations of the data stored in one or several B<RRD>s. Apart
50 from generating graphs, it can also extract numerical reports.
51
52 =over
53
54 =item I<filename> 
55
56 The name of the graph to generate. Since B<rrdtool> outputs
57 GIFs and PNGs, it's recommended that the filename end in either
58 F<.gif> or F<.png>.  B<rrdtool> does not enforce this, however.
59 If the  I<filename> is set to '-' the image file will be written
60 to standard out.  All other output will get suppressed.
61
62 PNG output is recommended, since it takes up to 40% less disk space
63 and 20-30% less time to generate than a GIF file.
64
65 If no graph functions are called, the graph will not be created.
66
67 =item B<-s>|B<--start> I<seconds> (default end-1day)
68
69 The time when the graph should begin. Time in seconds since
70 epoch (1970-01-01) is required. Negative numbers are relative to the
71 current time. By default one day worth of data will be graphed.
72 See also AT-STYLE TIME SPECIFICATION section in the I<rrdfetch>
73 documentation for a detailed explanation on how to specify time.
74
75 =item B<-e>|B<--end> I<seconds> (default now)
76
77 The time when the graph should end. Time in seconds since epoch.
78 See also AT-STYLE TIME SPECIFICATION section in the I<rrdfetch>
79 documentation for a detailed explanation of ways to specify time.
80
81 =item B<-x>|B<--x-grid> I<x-axis grid and label> (default autoconfigure)
82
83 The x-axis label is quite complex to configure. So if you don't have
84 very special needs, you can rely on the autoconfiguration to get this
85 right.
86
87 If you want no x-grid at all, use the magic setting B<none>.
88
89 The x-axis label and grid can be configured, using the following format:
90
91 I<GTM>B<:>I<GST>B<:>I<MTM>B<:>I<MST>B<:>I<LTM>:I<LST>B<:>I<LPR>B<:>I<LFM>
92
93 You have to configure three elements making up the x-axis labels and
94 grid. The base grid (I<G??>), the major grid (I<M??>) and the labels
95 (I<L??>). The configuration is based on the idea that you first
96 specify a well known amount of time (I<?TM>) and then say how many
97 times it has to pass between each grid line or label (I<?ST>). For the
98 label you have to define two additional items: The precision of the
99 label in seconds (I<LPR>) and the strftime format used to generate the
100 text of the label (I<LFM>).
101
102 The I<?TM> elements must be one of the following keywords: B<SECOND>,
103 B<MINUTE>, B<HOUR>, B<DAY>, B<WEEK>, B<MONTH> or B<YEAR>.
104
105 If you wanted a graph with a base grid every 10 minutes and a major
106 one every hour, with labels every hour you would use the following
107 x-axis definition.
108
109 C<MINUTE:10:HOUR:1:HOUR:1:0:%X>
110
111 The precision in this example is 0 because the %X format is exact. If
112 the label was the name of the day, we would have had a precision of 24
113 hours, because when you say something like 'Monday' you mean the whole
114 day and not Monday morning 00:00. Thus the label should be positioned
115 at noon. By defining a precision of 24 hours or rather 86400 seconds,
116 you make sure that this happens.
117
118 =item B<-y>|B<--y-grid> I<grid step>:I<label factor> (default autoconfigure)
119
120 Makes vertical grid lines appear at I<grid step> interval. Every
121 I<label factor> gridstep, a major grid line is printed, along with
122 label showing the value of the grid line.
123
124 If you want no y-grid at all set specify the magic word B<none>.
125
126 =item B<--alt-y-grid>
127
128 Place Y grid dynamically based on graph Y range. Algorithm ensures
129 that you always have grid, that there are enough but not too many
130 grid lines and the grid is metric. That is grid lines are placed 
131 every 1, 2, 5 or 10 units.  (contributed by Sasha Mikheev)
132
133
134 =item B<--alt-autoscale>
135
136 Compute Y range  based on function absolute minimum and 
137 maximum values. Default algorithm uses predefined set of ranges.  
138 This is good in many cases but it fails miserably when you need
139 to graph something like 260 + 0.001 * sin(x). Default algorithm 
140 will use Y range from 250 to 300 and on the graph you will see
141 almost straight line. With --alt-autoscale Y range will be
142 from slightly less the 260 - 0.001 to slightly more then 260 + 0.001
143 and periodic behavior will be seen.   (contributed by Sasha Mikheev)
144
145 =item B<--alt-autoscale-max>
146
147 Where --alt-autoscale will modify both the absolute maximum AND minimum
148 values, this option will only affect the maximum value. The minimum 
149 value, if not defined on the command line, will be 0. This option can
150 be useful when graphing router traffic when the WAN line uses compression,
151 and thus the throughput may be higher than the WAN line speed.
152
153 =item B<--units-exponent> I<value> (default autoconfigure)
154
155 This sets the 10**exponent scaling of the y-axis values.  Normally
156 values will be scaled to the appropriate units (k, M, etc.).  However
157 you may wish to display units always in k (Kilo, 10e3) even if the data
158 is in the M (Mega, 10e6) range for instance.  Value should be an
159 integer which is a multiple of 3 between -18 and 18 inclusive.  It is
160 the exponent on the units you which to use.  For example, use 3 to
161 display the y-axis values in k (Kilo, 10e3, thousands), use -6 to
162 display the y-axis values in u (Micro, 10e-6, millionths).  Use a value
163 of 0 to prevent any scaling of the y-axis values.
164
165 =item B<-v>|B<--vertical-label> I<text>
166
167 vertical label on the left side of the graph. This is normally used to
168 specify the units used.
169
170 =item B<-w>|B<--width> I<pixels> (default 400 pixel)
171
172 Width of the drawing area within the graph. This affects the size of the
173 gif.
174
175 =item B<-h>|B<--height> I<pixels> (default 100 pixel)
176
177 Width of the drawing area within the graph. This affects the size of the
178 gif.
179
180 =item B<-i>|B<--interlaced> (default: false)
181
182 If you set this option, then the resulting GIF will be interlaced.
183 Most web browsers display these incrementally as they load. If
184 you do not use this option, the GIFs default to being progressive
185 scanned. The only effect of this option is to control the format
186 of the GIF on disk. It makes no changes to the layout or contents
187 of the graph.
188
189 =item B<-f>|B<--imginfo> I<formatstring>
190
191 After the image has been created, the graph function uses printf
192 together with this format string to create output similar to the PRINT
193 function, only that the printf is supplied with the parameters
194 I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag
195 suitable for including the graph into a web page, the command line
196 would look like this:
197
198  --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
199
200 =item B<-a>|B<--imgformat> B<GIF>|B<PNG> (default: GIF)
201
202 Allows you to produce PNG output from rrdtool. 
203
204 =item B<-z>|B<--lazy> (default: false)
205
206 Only generate the graph, if the current gif is out of date or not
207 existent.
208
209 =item B<-u>|B<--upper-limit> I<value> (default autoconfigure)
210
211 Defines the value normally located at the upper border of the
212 graph. If the graph contains higher values, the upper border will
213 move upwards to accomodate these values as well.
214
215 If you want to define an upper-limit which will not move in any
216 event you have to set the B<--rigid> option as well.
217
218 =item B<-l>|B<--lower-limit> I<value> (default autoconfigure)
219
220 This is not the lower limit of a graph.  But rather, this is the
221 maximum lower bound of a graph.  For example, the value -100 will
222 result in a graph that has a lower limit of -100 or less.  Use this
223 keyword to expand graphs down.
224
225 =item B<-r>|B<--rigid>
226
227 rigid boundaries mode.  Normally rrdgraph will automatically expand the
228 lower and upper limit if the graph contains a value outside the valid
229 range. With the r option you can disable this behavior
230
231 =item B<-b>|B<--base> I<value>
232
233 if you are graphing memory (and NOT network traffic) this switch
234 should be set to 1024 so that one Kb is 1024 byte. For traffic
235 measurement, 1 kb/s is 1000 b/s.
236
237 =item B<-o>|B<--logarithmic>
238
239 logarithmic y-axis scaling
240
241 =item B<-c>|B<--color> I<COLORTAG>B<#>I<rrggbb> (default colors)
242
243 override the colors for the standard elements of the graph. The I<COLORTAG>
244 must be one of the following symbolic names: B<BACK> ground, B<CANVAS>,
245 B<SHADEA> left/top border, B<SHADEB> right/bottom border, B<GRID>, B<MGRID>
246 major grid, B<FONT>, B<FRAME> and axis of the graph or B<ARROW>. This option
247 can be called multiple times to set several colors.
248
249 =item B<-g>|B<--no-legend>
250
251 Suppress generation of legend; only render the graph.
252
253 =item B<-t>|B<--title> I<text> (default no title)
254
255 Define a title to be written into the graph
256
257 =item B<--step> I<value> (default automatic)
258
259 By default rrdgraph calculates the width of one pixle in the time domain and
260 tries to get data at that resolution from the RRD. With this switch you can
261 override this behaviour. If you want rrdgraph to get data at 1 hour
262 resolution from the RRD, then you can set the step to 3600 seconds. Note,
263 that a step smaller than 1 pixle will be silently ignored.
264
265 =item B<DEF:>I<vname>B<=>I<rrd>B<:>I<ds-name>B<:>I<CF>
266
267 Define virtual name for a data source. This name can then be used
268 in the functions explained below. The
269 DEF call automatically chooses an B<RRA> which contains I<CF> consolidated data in a
270 resolution appropriate for the size of the graph to be drawn.  Ideally
271 this means that one data point from the B<RRA> should be represented
272 by one pixel in the graph.  If the resolution of the B<RRA> is higher
273 than the resolution of the graph, the data in the RRA will be further
274 consolidated according to the consolidation function (I<CF>) chosen.
275
276 =item B<CDEF:>I<vname>B<=>I<rpn-expression>
277
278 Create a new virtual data source by evaluating a mathematical expression,
279 specified in Reverse Polish Notation (RPN). If you have ever used a traditional
280 HP calculator you already know RPN. The idea behind RPN notation is, 
281 that you have a stack and push your data onto this stack. When ever
282 you execute an operation, it takes as many data values from the stack
283 as needed. The pushing of data is implicit, so when ever you specify a number
284 or a variable, it gets pushed automatically. 
285
286 If this is all a big load of incomprehensible words for you, maybe an
287 example helps (a more complete explanation is given in [1]): The
288 expression I<vname+3/2> becomes C<vname,3,2,/,+> in RPN. First the three
289 values get pushed onto the stack (which now contains (the current
290 value of) vname, a 3 and a 2).  Then the / operator pops two values
291 from the stack (3 and 2), divides the first argument by the second
292 (3/2) and pushes the result (1.5) back onto the stack. Then the +
293 operator pops two values (vname and 1.5) from the stack; both values
294 are added up and the result gets pushes back onto the stack. In the
295 end there is only one value left on the stack: The result of the
296 expression.
297
298 The I<rpn-expression> in the B<CDEF> function takes both, constant values
299 as well as I<vname> variables. The following operators can be used on these
300 values: 
301
302 =over
303
304 =item +, -, *, /, %
305
306 pops two values from the stack applies the selected operator and pushes 
307 the result back onto the stack. The % operator stands for the modulo
308 operation.
309
310 =item SIN, COS, LOG, EXP, FLOOR, CEIL
311
312 pops one value from the stack, applies the selected function and pushes
313 the result back onto the stack.
314
315 =item LT, LE, GT, GE, EQ
316
317 pops two values from the stack, compares them according to the selected
318 condition and pushes either 1 back onto the stack if the condition is true
319 and 0 if the condition was not true.
320
321 =item IF
322
323 pops three values from the stack. If the last value is not 0, the
324 second value will be pushed back onto the stack, otherwise the
325 first value is pushed back.
326
327 If the stack contains the values A, B, C, D, E are presently on the
328 stack, the IF operator will pop the values E D and C of the stack. It will
329 look at C and if it is not 0 it will push D back onto the stack, otherwise
330 E will be sent back to the stack.
331
332 =item MIN, MAX
333
334 selects the lesser or larger of the two top stack values respectively
335
336 =item LIMIT
337
338 replaces the value with I<*UNKNOWN*> if it is outside the limits specified
339 by the two values above it on the stack.
340
341  CDEF:a=alpha,0,100,LIMIT
342
343 =item DUP, EXC, POP
344
345 These manipulate the stack directly.  DUP will duplicate the top of the
346 stack, pushing the result back onto the stack.  EXC will exchange the top
347 two elements of the stack, and POP will pop off the top element of the
348 stack.  Having insufficient elements on the stack for these operations is
349 an error.
350
351 =item UN
352
353 Pops one value off the stack, if it is I<*UNKNOWN*>, 1 will be pushed
354 back otherwise 0.
355
356 =item UNKN
357
358 Push an I<*UNKNOWN*> value onto the stack.
359
360 =item PREV
361
362 Push I<*UNKNOWN*> if its at the first value of a data set or otherwise
363 the value of this CDEF at the previous time step. This allows you to
364 perform calculations across the data.
365
366 =item INF, NEGINF
367
368 Push a positive or negative infinite (oo) value onto the stack. When
369 drawing an infinite number it appears right at the top or bottom edge of the
370 graph, depending whether you have a positive or negative infinite number.
371
372 =item NOW
373
374 Push the current (real world) time onto the stack.
375
376 =item TIME
377
378 Push the time the current sample was taken onto the stack. This is the
379 number of non-skip seconds since 0:00:00 January 1, 1970.
380
381 =item LTIME
382
383 This is like TIME B<+ current timezone offset in seconds>. The current
384 offset takes daylight saving time into account, given your OS supports
385 this. If you were looking at a sample, in Zurich, in summer, the
386 offset would be 2*3600 seconds, as Zurich at that time of year is 2
387 hours ahead of UTC.
388
389 Note that the timezone offset is always calculated for the time the
390 current sample was taken at. It has nuthing todo with the time you are
391 doing the calculation.
392
393 =back
394
395 Please note that you may only use I<vname> variables that you
396 previously defined by either B<DEF> or B<CDEF>. Furthermore, as of
397 this writing (version 0.99.25), you must use at least one I<vname>
398 per expression, that is "CDEF:fourtytwo=2,40,+" will yield an error
399 message but not a I<vname> fourtytwo that's always equal to 42.
400
401 =item B<PRINT:>I<vname>B<:>I<CF>B<:>I<format>
402
403 Calculate the chosen consolidation function I<CF> over the data-source
404 variable I<vname> and C<printf> the result to stdout using I<format>.
405 In the I<format> string there should be a '%lf' or '%le' marker in the
406 place where the number should be printed.
407
408 If an additional '%s' is found AFTER the marker, the value will be scaled
409 and an appropriate SI magnitude unit will be printed in place of the '%s'
410 marker. The scaling will take the '--base' argument into consideration!
411
412 If a '%S' is used instead of a '%s', then instead of calculating the
413 appropriate SI magnitude unit for this value, the previously calculated
414 SI magnitude unit will be used.  This is useful if you want all the values
415 in a PRINT statement to have the same SI magnitude unit.  If there was
416 no previous SI magnitude calculation made, then '%S' behaves like a '%s',
417 unless the value is 0, in which case it does not remember a SI magnitude
418 unit and a SI magnitude unit will only be calculated when the next '%s' is
419 seen or the next '%S' for a non-zero value.
420
421 If you want to put a '%' into your PRINT string, use '%%' instead.
422
423 =item B<GPRINT:>I<vname>B<:>I<CF>B<:>I<format>
424
425 Same as B<PRINT> but the result is printed into the graph below the legend.
426
427 =back
428
429 B<Caveat:> When using the B<PRINT> and B<GRPRINT> functions to
430 calculate data summaries over time periods bounded by the current
431 time, it is important to note that the last sample will almost always
432 yield a value of UNKNOWN as it lies after the last update time.  This
433 can result in slight data skewing, particularly with the B<AVERAGE>
434 function.  In order to avoid this, make sure that your end time is at
435 least one heartbeat prior to the current time.
436
437 =over
438
439
440 =item B<COMMENT:>I<text>
441
442 Like B<GPRINT> but the I<text> is simply printed into the graph.
443
444 =item B<HRULE:>I<value>B<#>I<rrggbb>[B<:>I<legend>]
445
446 Draw a horizontal rule into the graph and optionally add a legend
447
448 =item B<VRULE:>I<time>B<#>I<rrggbb>[B<:>I<legend>]
449
450 Draw a vertical rule into the graph and optionally add a legend
451
452 =item B<LINE>{B<1>|B<2>|B<3>}B<:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]
453
454 Plot for the requested data, using the color specified. Write a legend
455 into the graph. The 3 possible keywords B<LINE1>, B<LINE2>, and B<LINE3> 
456 generate increasingly wide lines. If no color is defined, 
457 the drawing is done 'blind' this is useful in connection with the 
458 B<STACK> function when you want to ADD the values of two 
459 data-sources without showing it in the graph.
460
461 =item B<AREA>:I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]
462
463 Does the same as B<LINE?>, but the area between 0 and 
464 the graph will be filled with the color specified.
465
466 =item B<STACK>:I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]
467
468 Does the same as B<LINE?>, but the graph gets stacked on top of the previous
469 B<LINE?>, B<AREA> or B<STACK> graph. Depending on the type of the
470 previous graph, the B<STACK> will be either a B<LINE?> or an B<AREA>.
471 This obviously implies that the first B<STACK> must be preceded by an
472 B<AREA> or B<LINE?> -- you need something to stack something onto in
473 the first place ;) 
474
475 Note, that when you STACK onto *UNKNOWN* data, rrdtool will not draw
476 any graphics ... *UNKNOWN* is not zero ... if you want it to be zero
477 then you might want to use a CDEF argument with IF and UN functions to
478 turn *UNKNOWN* into zero ...
479
480 =item B<TICK:>I<vname>B<#>I<rrggbb>[B<:>I<axis-fraction>[B<:>I<legend>]]
481
482 Plot a tick mark (a vertical line) for each value of I<vname> that is
483 non-zero and not *UNKNOWN*. The I<axis-fraction> argument specifies the
484 length of the tick mark as a fraction of the y-axis; the default value
485 is 0.1 (10% of the axis). Note that the color specification is not
486 optional.
487
488 =back
489
490 =head1 NOTES on legend arguments
491
492 =head2 Escaping the colon
493
494 In a ':' in a I<legend> argument will mark the end of the legend. To
495 enter a ':' into a legend, the colon must be escaped with a backslash '\:'.
496 Beware, that many environments look for backslashes themselves, so it may
497 be necessary to write two backslashes so that one is passed onto rrd_graph.
498
499 =head2 String Formatting
500
501 The text printed below the actual graph can be formated by appending special
502 escaped characters at the end of a text. When ever such a character occurs,
503 all pending text is pushed onto the graph according to the character
504 specified.
505
506 Valid markers are: B<\j> for justified, B<\l> for left aligned, B<\r> for
507 right aligned and B<\c> for centered. In the next section there is an
508 example showing how to use centered formating.
509
510 Normally there are two space characters inserted between every two items
511 printed into the graph. The space following a string can be suppressed by
512 putting a B<\g> at the end of the string. The B<\g> also squshes any space
513 inside the string if it is at the very end of the string. This can be used
514 in connection with B<%s> to supress empty unit strings.
515
516  GPRINT:a:MAX:%lf%s\g
517
518 A special case is COMMENT:B<\s> this inserts some additional vertical space
519 before placing the next row of legends.
520
521 =head1 NOTE on Return Values
522
523 Whenever rrd_graph gets called, it prints a line telling the size of
524 the gif it has just created to STDOUT. This line looks like this: XSIZExYSIZE.
525
526 =head1 EXAMPLE 1
527
528   rrdtool graph demo.gif --title="Demo Graph" \
529           DEF:cel=demo.rrd:exhaust:AVERAGE \
530           "CDEF:far=cel,1.8,*,32,+"" \
531           LINE2:cel#00a000:"D. Celsius" \
532           LINE2:far#ff0000:"D. Fahrenheit\c"
533
534 =head1 EXAMPLE 2
535
536 This example demonstrates the syntax for using IF and UN to set
537 I<*UNKNOWN*> values to 0.  This technique is useful if you are
538 aggregating interface data where the start dates of the data sets
539 doesn't match.
540
541   rrdtool graph demo.gif --title="Demo Graph" \
542          DEF:idat1=interface1.rrd:ds0:AVERAGE \
543          DEF:idat2=interface2.rrd:ds0:AVERAGE \
544          DEF:odat1=interface1.rrd:ds1:AVERAGE \
545          DEF:odat2=interface2.rrd:ds1:AVERAGE \
546          CDEF:agginput=idat1,UN,0,idat1,IF,idat2,UN,0,idat2,IF,+,8,* \
547          CDEF:aggoutput=odat1,UN,0,odat1,IF,odat2,UN,0,odat2,IF,+,8,* \
548          AREA:agginput#00cc00:Input Aggregate \
549          LINE1:agginput#0000FF:Output Aggregate
550          
551 Assuming that idat1 has a data value of I<*UNKNOWN*>, the CDEF expression 
552
553  idat1,UN,0,idat1,IF 
554
555 leaves us with a stack with contents of 1,0,NaN and the IF function
556 will pop off the 3 values and replace them with 0.  If idat1 had a
557 real value like 7942099, then the stack would have 0,0,7942099 and the
558 real value would be the replacement.  
559
560 =head1 EXAMPLE 3
561
562 This example shows two ways to use the INF function. First it makes
563 the background change color during half of the hours. Then, it uses
564 AREA and STACK to draw a picture. If one of the inputs was UNKNOWN,
565 all inputs are overlaid with another AREA.
566
567   rrdtool graph example.png --title="INF demo" \
568          DEF:val1=some.rrd:ds0:AVERAGE \
569          DEF:val2=some.rrd:ds1:AVERAGE \
570          DEF:val3=some.rrd:ds2:AVERAGE \
571          DEF:val4=other.rrd:ds0:AVERAGE \
572          CDEF:background=val4,POP,TIME,7200,%,3600,LE,INF,UNKN,IF \
573          CDEF:wipeout=val1,val2,val3,val4,+,+,+,UN,INF,UNKN,IF \
574          AREA:background#F0F0F0 \
575          AREA:val1#0000FF:Value1 \
576          STACK:val2#00C000:Value2 \
577          STACK:val3#FFFF00:Value3 \
578          STACK:val4#FFC000:Value4 \
579          AREA:wipeout#FF0000:Unknown
580
581 The first CDEF uses val4 as a dummy value. It's value is removed immediately
582 from the stack. Then a decision is made based on the time that a sample was
583 taken. If it is an even hour (UTC time !) then the area will be filled. If
584 it is not, the value is set to UNKN and is not plotted.
585
586 The second CDEF looks if any of val1,val2,val3,val4 is unknown. It does so by
587 checking the outcome of sum(val1,val2,val3,val4). Again, INF is returned when
588 the condition is true, UNKN is used to not plot the data.
589
590 The different items are plotted in a particular order. First do the background, then use a
591 normal area to overlay it with data. Stack the other data until they are all plotted. Last but
592 not least, overlay everything with eye-hurting red
593 to signal any unknown data.
594
595 Note that this example assumes that your data is in the positive half of the y-axis
596 otherwhise you would would have to add NEGINF in order to extend the coverage
597 of the rea to whole graph.
598
599 =head1 EXAMPLE 4
600
601 If the specialized function B<RRAs> exist for aberrant behavior detection, they
602 can be used to generate the graph of a time series with confidence bands and
603 failures.
604
605    rrdtool graph example.gif \
606           DEF:obs=monitor.rrd:ifOutOctets:AVERAGE \
607           DEF:pred=monitor.rrd:ifOutOctets:HWPREDICT \
608           DEF:dev=monitor.rrd:ifOutOctets:DEVPREDICT \
609           DEF:fail=monitor.rrd:ifOutOctets:FAILURES \
610           TICK:fail#ffffa0:1.0:"Failures\: Average bits out" \
611           CDEF:scaledobs=obs,8,* \
612           CDEF:upper=pred,dev,2,*,+ \
613           CDEF:lower=pred,dev,2,*,- \
614           CDEF:scaledupper=upper,8,* \
615           CDEF:scaledlower=lower,8,* \
616           LINE2:scaledobs#0000ff:"Average bits out" \
617           LINE1:scaledupper#ff0000:"Upper Confidence Bound: Average bits out" \
618           LINE1:scaledlower#ff0000:"Lower Confidence Bound: Average bits out"
619
620 This example generates a graph of the data series in blue (LINE2 with the scaledobs
621 virtual data source), confidence bounds in red (scaledupper and scaledlower virtual
622 data sources), and potential failures (i.e. potential aberrant aberrant behavior)
623 marked by vertical yellow lines (the fail data source).
624
625 The raw data comes from an AVERAGE B<RRA>, the finest resolution of the observed
626 time series (one consolidated data point per primary data point). The predicted
627 (or smoothed) values are stored in the HWPREDICT B<RRA>. The predicted deviations
628 (think standard deviation) values are stored in the DEVPREDICT B<RRA>. Finally,
629 the FAILURES B<RRA> contains indicators, with 1 denoting a potential failure.
630
631 All of the data is rescaled to bits (instead of Octets) by multiplying by 8.
632 The confidence bounds are computed by an offset of 2 deviations both above
633 and below the predicted values (the CDEFs upper and lower). Vertical lines
634 indicated potential failures are graphed via the TICK graph element, which
635 converts non-zero values in an B<RRA> into tick marks. Here an axis-fraction
636 argument of 1.0 means the tick marks span the entire y-axis, and hence become
637 vertical lines on the graph.
638
639 The choice of 2 deviations (a scaling factor) matches the default used internally
640 by the FAILURES B<RRA>. If the internal value is changed (see L<rrdtune>), this
641 graphing command should be changed to be consistent.
642
643 =head2 A note on data reduction:
644
645 The B<rrdtool> I<graph> command is designed to plot data at a specified temporal
646 resolution, regardless of the actually resolution of the data in the RRD file.
647 This can present a problem for the specialized consolidation functions which
648 maintain a one-to-one mapping between primary data points and consolidated
649 data points. If a graph insists on viewing the contents of these B<RRAs> on a
650 coarser temporal scale, the I<graph> command tries to do something intelligent,
651 but the confidence bands and failures no longer have the same meaning and may
652 be misleading.
653
654 =head1 AUTHOR
655
656 Tobias Oetiker E<lt>oetiker@ee.ethz.chE<gt>
657
658 =head1 REFERENCES
659
660 [1] http://www.dotpoint.com/xnumber/rpn_or_adl.htm