Code

dfed5f1d7cbd69b844a1486d9eb4fc14e508b489
[pkg-rrdtool.git] / doc / rrdgraph_data.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>rrdgraph_data</title>
5 <link rev="made" href="mailto:root@localhost" />
6 </head>
8 <body style="background-color: white">
10 <p><a name="__index__"></a></p>
11 <!-- INDEX BEGIN -->
12 <!--
14 <ul>
16         <li><a href="#name">NAME</a></li>
17         <li><a href="#synopsis">SYNOPSIS</a></li>
18         <li><a href="#description">DESCRIPTION</a></li>
19         <li><a href="#def">DEF</a></li>
20         <li><a href="#vdef">VDEF</a></li>
21         <li><a href="#cdef">CDEF</a></li>
22         <li><a href="#about_cdef_versus_vdef">About CDEF versus VDEF</a></li>
23         <ul>
25                 <li><a href="#when_do_you_use_vdef_versus_cdef">When do you use <strong>VDEF</strong> versus <strong>CDEF</strong>?</a></li>
26         </ul>
28         <li><a href="#see_also">SEE ALSO</a></li>
29         <li><a href="#author">AUTHOR</a></li>
30 </ul>
31 -->
32 <!-- INDEX END -->
34 <p>
35 </p>
36 <h1><a name="name">NAME</a></h1>
37 <p>rrdgraph_data - preparing data for graphing in rrdtool graph</p>
38 <p>
39 </p>
40 <hr />
41 <h1><a name="synopsis">SYNOPSIS</a></h1>
42 <p><strong>DEF:</strong><em>&lt;vname&gt;</em>=<em>&lt;rrdfile&gt;</em>:<em>&lt;ds-name&gt;</em>:<em>&lt;CF&gt;</em>[:step=<em>&lt;step&gt;</em>][:start=<em>&lt;time&gt;</em>][:end=<em>&lt;time&gt;</em>][:reduce=<em>&lt;<strong>CF</strong>&gt;</em>]</p>
43 <p><strong>VDEF</strong>:<em>vname</em>=<em>RPN expression</em></p>
44 <p><strong>CDEF</strong>:<em>vname</em>=<em>RPN expression</em></p>
45 <p>
46 </p>
47 <hr />
48 <h1><a name="description">DESCRIPTION</a></h1>
49 <p>These three instructions extract data values out of the <strong>RRD</strong> files,
50 optionally altering them (think, for example, of a bytes to bits
51 conversion). If so desired, you can also define variables containing
52 useful information such as maximum, minimum etcetera. Two of the
53 instructions use a language called <strong>RPN</strong> which is described in its
54 own manual page.</p>
55 <p>Variable names (<em>vname</em>) must be made up strings of the following characters
56 <code>A-Z, a-z, 0-9, -,_</code> and a maximum length of 255 characters.</p>
57 <p>When picking variable names, make sure you do not choose a name that is
58 already taken by an RPN operator. A safe bet it to use lowercase or
59 mixedcase names for variables since operators will always be in uppercase.</p>
60 <p>
61 </p>
62 <hr />
63 <h1><a name="def">DEF</a></h1>
64 <p><strong>DEF:</strong><em>&lt;vname&gt;</em>=<em>&lt;rrdfile&gt;</em>:<em>&lt;ds-name&gt;</em>:<em>&lt;CF&gt;</em>[:step=<em>&lt;step&gt;</em>][:start=<em>&lt;time&gt;</em>][:end=<em>&lt;time&gt;</em>][:reduce=<em>&lt;<strong>CF</strong>&gt;</em>]</p>
65 <p>This command fetches data from an <strong>RRD</strong> file.  The virtual name
66 <em>vname</em> can then be used throughout the rest of the script. By
67 default, an <strong>RRA</strong> which contains the correct consolidated data
68 at an appropriate resolution will be chosen.  The resolution can
69 be overridden with the <a href="././rrdgraph.html#item_time">--step</a> option.
70 The resolution can again be overridden by specifying the <strong>step size</strong>.
71 The time span of this data is the same as for the graph by default,
72 you can override this by specifying <strong>start and end</strong>.  Remember to
73 escape colons in the time specification!</p>
74 <p>If the resolution of the data is higher than the resolution of the
75 graph, the data will be further consolidated. This may result in
76 a graph that spans slightly more time than requested.
77 Ideally each point in the graph should correspond with one <strong>CDP</strong>
78 from an <strong>RRA</strong>.  For instance, if your <strong>RRD</strong> has an <strong>RRA</strong> with
79 a resolution of 1800 seconds per <strong>CDP</strong>, you should create an
80 image with width 400 and time span 400*1800 seconds (use appropriate
81 start and end times, such as <code>--start end-8days8hours</code>).</p>
82 <p>If consolidation needs to be done, the <strong>CF</strong> of the <strong>RRA</strong> specified in the
83 <strong>DEF</strong> itself will be used to reduce the data density. This behaviour can
84 be changed using <code>:reduce=&lt;CF&gt;</code>.  This optional parameter
85 specifies the <strong>CF</strong> to use during the data reduction phase.</p>
86 <p>Example:</p>
87 <pre>
88         DEF:ds0=router.rrd:ds0:AVERAGE
89         DEF:ds0weekly=router.rrd:ds0:AVERAGE:step=7200
90         DEF:ds0weekly=router.rrd:ds0:AVERAGE:start=end-1h
91         DEF:ds0weekly=router.rrd:ds0:AVERAGE:start=11\:00:end=start+1h</pre>
92 <p>
93 </p>
94 <hr />
95 <h1><a name="vdef">VDEF</a></h1>
96 <p><strong>VDEF</strong>:<em>vname</em>=<em>RPN expression</em></p>
97 <p>This command returns a value and/or a time according to the <strong>RPN</strong>
98 statements used. The resulting <em>vname</em> will, depending on the
99 functions used, have a value and a time component.  When you use
100 this <em>vname</em> in another <strong>RPN</strong> expression, you are effectively
101 inserting its value just as if you had put a number at that place.
102 The variable can also be used in the various graph and print
103 elements.</p>
104 <p>Example: <code>VDEF:avg=mydata,AVERAGE</code></p>
105 <p>Note that currently only aggregation functions work in VDEF rpn expressions.
106 Patches to change this are welcome.</p>
107 <p>
108 </p>
109 <hr />
110 <h1><a name="cdef">CDEF</a></h1>
111 <p><strong>CDEF</strong>:<em>vname</em>=<em>RPN expression</em></p>
112 <p>This command creates a new set of data points (in memory only, not
113 in the <strong>RRD</strong> file) out of one or more other data series. The <strong>RPN</strong>
114 instructions are used to evaluate a mathematical function on each
115 data point. The resulting <em>vname</em> can then be used further on in
116 the script, just as if it were generated by a <strong>DEF</strong> instruction.</p>
117 <p>Example: <code>CDEF:mydatabits=mydata,8,*</code></p>
118 <p>
119 </p>
120 <hr />
121 <h1><a name="about_cdef_versus_vdef">About CDEF versus VDEF</a></h1>
122 <p>At some point in processing, <strong>RRDtool</strong> has gathered an array of rates
123 ready to display.</p>
124 <p><strong>CDEF</strong> works on such an array.  For example, <em>CDEF:new=ds0,8,*</em>
125 would multiply each of the array members by eight (probably
126 transforming bytes into bits). The result is an array containing the
127 new values.</p>
128 <p><strong>VDEF</strong> also works on such an array but in a different way.  For
129 example, <em>VDEF:max=ds0,MAXIMUM</em> would scan each of the array members
130 and store the maximum value.</p>
131 <p>
132 </p>
133 <h2><a name="when_do_you_use_vdef_versus_cdef">When do you use <strong>VDEF</strong> versus <strong>CDEF</strong>?</a></h2>
134 <p>Use <strong>CDEF</strong> to transform your data prior to graphing.  In the above
135 example, we'd use a <strong>CDEF</strong> to transform bytes to bits before
136 graphing the bits.</p>
137 <p>You use a <strong>VDEF</strong> if you want <em>max(1,5,3,2,4)</em> to return five which
138 would be displayed in the graph's legend (to answer, what was the
139 maximum value during the graph period).</p>
140 <p>If you want to apply 'complex' operations to the result of a VDEF you have
141 to use a CDEF again since VDEFs only look like RPN expressions, they aren't
142 realy.</p>
143 <p>
144 </p>
145 <hr />
146 <h1><a name="see_also">SEE ALSO</a></h1>
147 <p><a href="././rrdgraph.html">the rrdgraph manpage</a> gives an overview of how <strong>rrdtool graph</strong> works.
148 <a href="././rrdgraph_data.html">the rrdgraph_data manpage</a> describes <strong>DEF</strong>,<strong>CDEF</strong> and <strong>VDEF</strong> in detail.
149 <a href="././rrdgraph_rpn.html">the rrdgraph_rpn manpage</a> describes the <strong>RPN</strong> language used in the <strong>?DEF</strong> statements.
150 <a href="././rrdgraph_graph.html">the rrdgraph_graph manpage</a> page describes all of the graph and print functions.</p>
151 <p>Make sure to read <a href="././rrdgraph_examples.html">the rrdgraph_examples manpage</a> for tips&amp;tricks.</p>
152 <p>
153 </p>
154 <hr />
155 <h1><a name="author">AUTHOR</a></h1>
156 <p>Program by Tobias Oetiker &lt;<a href="mailto:tobi@oetiker.ch">tobi@oetiker.ch</a>&gt;</p>
157 <p>This manual page by Alex van den Bogaerdt &lt;<a href="mailto:alex@vandenbogaerdt.nl">alex@vandenbogaerdt.nl</a>&gt;
158 with corrections and/or additions by several people</p>
160 </body>
162 </html>