Fixed various typos in the manpages. Debian bug #550919. -- Justin T. Pryzby
[rrdtool.git] / doc / rrdgraph_data.pod
1 =head1 NAME
2
3 rrdgraph_data - preparing data for graphing in rrdtool graph
4
5 =head1 SYNOPSIS
6
7 B<DEF:>I<E<lt>vnameE<gt>>=I<E<lt>rrdfileE<gt>>:I<E<lt>ds-nameE<gt>>:I<E<lt>CFE<gt>>[:step=I<E<lt>stepE<gt>>][:start=I<E<lt>timeE<gt>>][:end=I<E<lt>timeE<gt>>][:reduce=I<E<lt>B<CF>E<gt>>]
8
9 B<VDEF>:I<vname>=I<RPN expression>
10
11 B<CDEF>:I<vname>=I<RPN expression>
12
13 =head1 DESCRIPTION
14
15 These three instructions extract data values out of the B<RRD> files,
16 optionally altering them (think, for example, of a bytes to bits
17 conversion). If so desired, you can also define variables containing
18 useful information such as maximum, minimum etcetera. Two of the
19 instructions use a language called B<RPN> which is described in its
20 own manual page.
21
22 Variable names (I<vname>) must be made up strings of the following characters
23 C<A-Z, a-z, 0-9, -,_> and a maximum length of 255 characters.
24
25 When picking variable names, make sure you do not choose a name that is
26 already taken by an RPN operator. A safe bet it to use lowercase or
27 mixed case names for variables since operators will always be in uppercase.
28
29 =head1 DEF
30
31 B<DEF:>I<E<lt>vnameE<gt>>=I<E<lt>rrdfileE<gt>>:I<E<lt>ds-nameE<gt>>:I<E<lt>CFE<gt>>[:step=I<E<lt>stepE<gt>>][:start=I<E<lt>timeE<gt>>][:end=I<E<lt>timeE<gt>>][:reduce=I<E<lt>B<CF>E<gt>>]
32
33 This command fetches data from an B<RRD> file.  The virtual name
34 I<vname> can then be used throughout the rest of the script. By
35 default, an B<RRA> which contains the correct consolidated data
36 at an appropriate resolution will be chosen.  The resolution can
37 be overridden with the L<--step|rrdgraph/item_Time> option.
38 The resolution can again be overridden by specifying the B<step size>.
39 The time span of this data is the same as for the graph by default,
40 you can override this by specifying B<start and end>.  Remember to
41 escape colons in the time specification!
42
43 If the resolution of the data is higher than the resolution of the
44 graph, the data will be further consolidated. This may result in
45 a graph that spans slightly more time than requested.
46 Ideally each point in the graph should correspond with one B<CDP>
47 from an B<RRA>.  For instance, if your B<RRD> has an B<RRA> with
48 a resolution of 1800 seconds per B<CDP>, you should create an
49 image with width 400 and time span 400*1800 seconds (use appropriate
50 start and end times, such as C<--start end-8days8hours>).
51
52 If consolidation needs to be done, the B<CF> of the B<RRA> specified in the
53 B<DEF> itself will be used to reduce the data density. This behavior can
54 be changed using C<:reduce=I<E<lt>B<CF>E<gt>>>.  This optional parameter
55 specifies the B<CF> to use during the data reduction phase.
56
57 Example:
58
59         DEF:ds0=router.rrd:ds0:AVERAGE
60         DEF:ds0weekly=router.rrd:ds0:AVERAGE:step=7200
61         DEF:ds0weekly=router.rrd:ds0:AVERAGE:start=end-1h
62         DEF:ds0weekly=router.rrd:ds0:AVERAGE:start=11\:00:end=start+1h
63
64 =head1 VDEF
65
66 B<VDEF>:I<vname>=I<RPN expression>
67
68 This command returns a value and/or a time according to the B<RPN>
69 statements used. The resulting I<vname> will, depending on the
70 functions used, have a value and a time component.  When you use
71 this I<vname> in another B<RPN> expression, you are effectively
72 inserting its value just as if you had put a number at that place.
73 The variable can also be used in the various graph and print
74 elements.
75
76 Example: C<VDEF:avg=mydata,AVERAGE>
77
78 Note that currently only aggregation functions work in VDEF rpn expressions.
79 Patches to change this are welcome.
80
81 =head1 CDEF
82
83 B<CDEF>:I<vname>=I<RPN expression>
84
85 This command creates a new set of data points (in memory only, not
86 in the B<RRD> file) out of one or more other data series. The B<RPN>
87 instructions are used to evaluate a mathematical function on each
88 data point. The resulting I<vname> can then be used further on in
89 the script, just as if it were generated by a B<DEF> instruction.
90
91 Example: C<CDEF:mydatabits=mydata,8,*>
92
93 =head1 About CDEF versus VDEF
94
95 At some point in processing, B<RRDtool> has gathered an array of rates
96 ready to display.
97
98 B<CDEF> works on such an array.  For example, I<CDEF:new=ds0,8,*>
99 would multiply each of the array members by eight (probably
100 transforming bytes into bits). The result is an array containing the
101 new values.
102
103 B<VDEF> also works on such an array but in a different way.  For
104 example, I<VDEF:max=ds0,MAXIMUM> would scan each of the array members
105 and store the maximum value.
106
107 =head2 When do you use B<VDEF> versus B<CDEF>?  
108
109 Use B<CDEF> to transform your data prior to graphing.  In the above
110 example, we'd use a B<CDEF> to transform bytes to bits before
111 graphing the bits.
112
113 You use a B<VDEF> if you want I<max(1,5,3,2,4)> to return five which
114 would be displayed in the graph's legend (to answer, what was the
115 maximum value during the graph period).
116
117 If you want to apply 'complex' operations to the result of a VDEF you have
118 to use a CDEF again since VDEFs only look like RPN expressions, they aren't
119 really.
120
121 =head1 SEE ALSO
122
123 L<rrdgraph> gives an overview of how B<rrdtool graph> works.
124 L<rrdgraph_data> describes B<DEF>,B<CDEF> and B<VDEF> in detail.
125 L<rrdgraph_rpn> describes the B<RPN> language used in the B<?DEF> statements.
126 L<rrdgraph_graph> page describes all of the graph and print functions.
127
128 Make sure to read L<rrdgraph_examples> for tipsE<amp>tricks.
129
130 =head1 AUTHOR
131
132 Program by Tobias Oetiker E<lt>tobi@oetiker.chE<gt>
133
134 This manual page by Alex van den Bogaerdt E<lt>alex@vandenbogaerdt.nlE<gt>
135 with corrections and/or additions by several people