complete rewrite of rrdgraph documentation. This also includs info
[rrdtool.git] / doc / rrdgraph.pod
1 =head1 NAME
2
3 rrdtool graph - Round Robin Database tool grapher functions
4
5 WARNING: This is for version 1.1.x which is B<I<BETA>> software.
6 The software may contain serious bugs. Some of the items
7 described in here may not yet exist (although this should
8 be mentioned) or still be in the alpha stage.  As with every
9 other RRDtool release: use at your own risk.  In contrast with
10 the stable version of RRDtool, this release may contain bugs
11 known to the authors.  It is highly recommended that you subscribe
12 to the mailing list.
13
14 =head1 SYNOPSYS
15
16 B<rrdtool graph> I<filename>
17 [E<lt>B<L<option|rrdgraph/OPTIONS>>E<gt> ...]
18 E<lt>B<L<data definition|rrdgraph_data/DEF>>E<gt>
19 [E<lt>B<L<data definition|rrdgraph_data/DEF>>E<gt> ...]
20 [E<lt>B<L<data calculation|rrdgraph_data/CDEF>>E<gt> ...]
21 [E<lt>B<L<variable definition|rrdgraph_data/VDEF>>E<gt> ...]
22 [E<lt>B<L<graph element|rrdgraph_graph/GRAPH>>E<gt> ...]
23 [E<lt>B<L<print element|rrdgraph_graph/PRINT>>E<gt> ...]
24
25 =head1 DESCRIPTION
26
27 The B<graph> function of B<RRDtool> is used to represent the
28 data from an B<RRD> to a human viewer.  Its main purpose is to
29 create a nice graphical representation but it can also generate
30 a numerical report.
31
32 =head1 OVERVIEW
33
34 B<rrdtool graph> needs data to work with, use one or more
35 B<L<data definition|rrdgraph_data/DEF>> statements to collect this
36 data.  You are not limited to one database, it's perfectly legal to
37 collect data from two or more databases (one per statement though).
38
39 If you want to display averages, maxima, percentiles etcetera
40 it is best to collect them now using the
41 B<L<variable definition|rrdgraph_data/VDEF>> statement.  At this
42 stage, this command works at the unprocessed data from the B<RRD>.
43 I<(Note: this is not yet true; it works on consolidated information
44 right now)>
45
46 The data fetched from the B<RRA> is then B<consolidated> so that
47 there is exactly one datapoint per pixel in the graph. If you do
48 not take care yourself, B<RRDtool> will expand the range slightly
49 if necessary (in that case the first pixel may very well become
50 unknown!).
51
52 Sometimes data is not exactly as you would like to display it. For
53 instance, you might be collecting B<bytes> per second but want to
54 display B<bits> per second. This is where the
55 B<L<data calculation|rrdgraph_data/CDEF>> command is designed for.
56 After B<consolidating> the data, a copy is made and this copy is
57 modified using a rather flexible B<L<RPN|rrdgraph_rpn/>> command
58 set.  If you use B<L<variable definition|rrdgraph_data/VDEF>>
59 statements after this, they work on the consolidated data and may
60 return other values for maximum, minimum etcetera!
61
62 When you are done fetching and processing the data, it is time to
63 graph it (or print it).  This ends the B<rrdtool graph> sequence.
64
65 =head1 OPTIONS
66
67 It is expected that most options will move to the graph definition
68 statements (after all, most of them do define graph elements...).
69
70 =over 4
71
72 =item filename
73
74 The name and path of the graph to generate. It is recommended to
75 end this in C<.png> or C<.gif> but B<rrdtool> does not enforce this.
76
77 I<filename> can be 'C<->' to send the image to C<stdout>. In
78 that case, no other output is generated.  
79
80 Z<>
81
82 =item Time range
83
84 B<[-s|--start E<lt>timeE<gt>]>
85 B<[-e|--end E<lt>timeE<gt>]>
86 B<[--step E<lt>secondsE<gt>]>
87
88 The start and end of what you would like to display, and which
89 B<RRA> the data should come from.  Defaults are: 1 day ago until
90 now, with the best possible resolution. B<Start> and B<end> can 
91 be specified in several formats, see
92 L<AT-STYLE TIME SPECIFICATION|rrdfetch/> and L<rrdgraph_examples>.
93 By default, B<rrdtool graph> calculates the width of one pixel in
94 the time domain and tries to get data from an B<RRA> with that
95 resolution.  With the B<step> option you can alter this behaviour.
96 If you want B<rrdtool graph> to get data at a one-hour resolution
97 from the B<RRD>, set B<step> to 3600.  Note: a step smaller than
98 one pixel will silently be ignored.
99
100 Z<>
101
102 =item Labels
103
104 B<[-t|--title E<lt>stringE<gt>]>
105 B<[-v|--vertical-label E<lt>stringE<gt>]>
106
107 A horizontal string at the top of the graph and/or a vertically
108 placed string at the left hand side of the graph. I<New: (not
109 yet implemented)> The string can contain formatter options that
110 are used to include variables (from B<VDEF>s) and newlines.
111
112 Z<>
113
114 =item Size
115
116 B<[-w|--width E<lt>pixelsE<gt>]>
117 B<[-h|--heigth E<lt>pixelsE<gt>]>
118
119 The width and height of the B<canvas> (the part of the graph with
120 the actual lines and such). Defaults are 400 pixels by 100 pixels.
121
122 Z<>
123
124 =item Limits
125
126 I<Old behaviour, until the new options are implemented>
127 B<[-u|--upper-limit E<lt>valueE<gt>]>
128 B<[-l|--lower-limit E<lt>valueE<gt>]>
129 B<[-r|--rigid]>
130
131 By default the graph will be autoscaling so that it displays the
132 portion of the y-axis that is actually used. You can change this
133 behaviour by setting the limits.  The displayed y-axis will show
134 at least from B<lower-limit> to B<upper-limit>.  Autoscaling will
135 still permit those boundaries to be stretched unless the B<rigid>
136 option is set.
137
138 I<New behaviour, after the new options are implemented>
139 B<[--maximum-upper-limit E<lt>valueE<gt>]>
140 B<[--minimum-upper-limit E<lt>valueE<gt>]>
141 B<[--maximum-lower-limit E<lt>valueE<gt>]>
142 B<[--minimum-lower-limit E<lt>valueE<gt>]>
143
144 By default the graph will be autoscaling so that it displays the
145 portion of the y-axis that is actually used. You can change this
146 behaviour by setting the limits.  The displayed y-axis will show
147 at most B<maximum-upper-limit> and at least B<minimum-upper-limit>
148 at the top, and similarily at least B<maximum-lower-limit> and
149 at most B<minimum-lower-limit> at the bottom.  The default is to
150 display at most B<infinity> (so: no limit) and at least
151 B<negative infinity> (no minimal value) at the top. The bottom of
152 the graph has similar defaults. Note that the minimum lower limit
153 is the lowest one so you should compare this with maximum upper
154 limit when you try to figure out what you should set.
155
156 To make sure the graph shows the range of I<-1000> to I<2000>,
157 optionally expanding to no more than I<-3000> to I<4000>,
158 set the following options:
159
160 --maximum-upper-limit 4000 --minimum-upper-limit 2000
161 --maximum-lower-limit -1000 --minimum-lower-limit -3000
162
163 To mimic the old B<rigid> option, you can do:
164
165 --maximum-upper-limit 4000 --minimum-upper-limit 4000
166 --maximum-lower-limit -3000 --minimum-lower-limit -3000
167
168 B<[--alt-autoscale]>
169
170 Sometimes the default algorithm for selecting the y-axis scale is not
171 performing very well.  Normally the scale is selected from a predefined
172 set of ranges and this fails miserably when you need to graph something
173 like C<260 + 0.001 * sin(x)>. This option calculates the minimum and
174 maximum y-axis from the actual minimum and maximum values. Our example
175 would display slightly less than C<260-0.001> to slightly more than
176 C<260+0.001> (Contributed by Sasha Mikheev).
177
178 B<[--alt-autoscale-max]>
179
180 Where C<--alt-autoscale> will modify both the absolute maximum AND minimum
181 values, this option will only affect the maximum value. The minimum
182 value, if not defined on the command line, will be 0. This option can
183 be useful when graphing router traffic when the WAN line uses compression,
184 and thus the throughput may be higher than the WAN line speed.
185
186 Z<>
187
188 =item Grid
189
190 =over 4
191
192 =item X-Axis
193
194 B<[-x|--x-grid E<lt>I<GTMC<:>GSTC<:>MTMC<:>MSTC<:>LTMC<:>LSTC<:>LPRC<:>LFM>E<gt>|C<none>]>
195
196 The x-axis label is quite complex to configure, if you don't have
197 very special needs it is probably best to rely on the autoconfiguration
198 to get this right.  You can specify the string C<none> to skip the grid
199 and labels altogether.
200
201 The grid is defined by specifying a certain amount of time in the I<?TM>
202 positions. You can choose from C<SECOND>, C<MINUTE>, C<HOUR>, C<DAY>,
203 C<WEEK>, C<MONTH> or C<YEAR>. Then you define how many of these should
204 pass between each line or label.  This pair (I<?TM:?ST>) needs to be
205 specified for the base grid (I<G??>), the major grid (I<M??>) and the
206 labels (I<L??>). For the labels you also need to define a precision
207 in I<LPR> and a I<strftime> format string in I<LFM>.  I<LPR> defines
208 where each label will be placed. If it is zero, the label will be
209 placed right under the corresponding line (useful for hours, dates
210 etcetera).  If you specify a number of seconds here the label is
211 centered in this interval (useful for monday, januari etcetera).
212
213 Example: C<--x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X>
214
215 This places grid lines every 10 minutes, major grid lines every hour
216 and labels every 4 hours. The labels are placed under the major grid
217 lines as they specify exactly that time.
218
219 Example: C<--x-grid HOUR:8:DAY:1:DAY:1:0:%A>
220
221 This places grid lines every 8 hours, major grid lines and labels
222 each day. The labels are placed exactly between two major grid lines
223 as they specify the complete day and not just midnight.
224
225 Z<>
226
227 =item Y-Axis
228
229 B<[-y|--y-grid I<E<lt>grid stepE<gt>:E<lt>label factorE<gt>>|C<none>]>
230
231 Y-axis grid lines appear at each I<grid step> interval.  Labels are
232 placed every I<label factor> lines.  You can specify C<-y none> to
233 skip the grid and labels altogether.  The default for this option is
234 to automatically select sensible values.
235
236 B<[--alt-y-grid]>
237
238 Place Y grid dynamically based on graph Y range. Algorithm ensures
239 that you always have grid, that there are enough but not too many
240 grid lines and the grid is metric. That is grid lines are placed
241 every 1, 2, 5 or 10 units.  (contributed by Sasha Mikheev)
242
243 B<[-o|--logarithmic]>
244
245 Logarithmic y-axis scaling.
246
247 B<[--units-exponent E<lt>valueE<gt>]>
248
249 This sets the 10**exponent scaling of the y-axis values.  Normally
250 values will be scaled to the appropriate units (k, M, etc.).  However
251 you may wish to display units always in k (Kilo, 10e3) even if the data
252 is in the M (Mega, 10e6) range for instance.  Value should be an
253 integer which is a multiple of 3 between -18 and 18 inclusive.  It is
254 the exponent on the units you which to use.  For example, use 3 to
255 display the y-axis values in k (Kilo, 10e3, thousands), use -6 to
256 display the y-axis values in u (Micro, 10e-6, millionths).  Use a value
257 of 0 to prevent any scaling of the y-axis values.
258
259 Z<>
260
261 =back
262
263 Z<>
264
265 =item Miscellaneous
266
267 B<[-z|--lazy]>
268
269 Only generate the graph, if the current graph is out of date or not
270 existent.
271
272 B<[-f|--imginfo E<lt>printfstrE<gt>]>
273
274 After the image has been created, the graph function uses printf
275 together with this format string to create output similar to the PRINT
276 function, only that the printf is supplied with the parameters
277 I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag
278 suitable for including the graph into a web page, the command line
279 would look like this:
280
281     --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
282
283 B<[-c|--color I<COLORTAG#rrggbb>]>
284
285 Override the default colors for the standard elements of the graph.
286 The I<COLORTAG> is one of C<BACK> ground, C<CANVAS>, C<SHADEA> for the
287 left and top border, C<SHADEB> for the right and bottom border, C<GRID>,
288 C<MGRID> for the major grid, C<FONT>, C<FRAME> and axis, C<ARROW>.
289 Each color is composed out of three hexadecimal numbers specifying
290 its color component (00 is off, FF is maximum) of red, green and blue.
291 You may set this option several times to alter multiple defaults.
292
293 A green arrow is made by: C<--color ARROW:00FF00>
294
295 B<[-a|--imgformat C<GIF>|C<PNG>]>
296 B<[-i|--interlaced]>
297
298 The default is to generate a non-interlaced GIF image. It is recommended
299 to generate PNG graphics as they take up to 40% less disk space and
300 20-30% less time to generate.
301
302 B<[-g|--no-legend]>
303
304 Suppress generation of legend; only render the graph.
305
306 B<[-b|--base E<lt>valueE<gt>]>
307
308 If you are graphing memory (and NOT network traffic) this switch
309 should be set to 1024 so that one Kb is 1024 byte. For traffic
310 measurement, 1 kb/s is 1000 b/s.
311
312 Z<>
313
314 =item Data and variables
315
316 B<DEF:>I<E<lt>vnameE<gt>>=I<E<lt>rrdfileE<gt>>:I<E<lt>ds-nameE<gt>>:I<E<lt>CFE<gt>>[:[I<E<lt>time rangeE<gt>>][:I<E<lt>step timeE<gt>>]]
317
318 B<CDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
319
320 B<VDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
321
322 You need at least one B<DEF> statement to generate anything. The
323 other statements are useful but optional.
324 See L<rrdgraph_data> and L<rrdgraph_rpn> for exact format.
325
326 Z<>
327
328 =item Graph and print elements
329
330 You need at least one graph element to generate an image and/or
331 at least one print statement to generate a report.
332 See L<rrdgraph_graph> for exact format.
333
334 =back
335
336 =head1 SEE ALSO
337
338 L<rrdgraph> gives an overview of how B<rrdtool graph> works.
339 L<rrdgraph_data> describes B<DEF>,B<CDEF> and B<VDEF> in detail,
340 L<rrdgraph_rpn> describes the B<RPN> language used in the B<?DEF> statements,
341 L<rrdgraph_graph> page describes all of the graph and print functions.
342
343 Make sure to read L<rrdgraph_examples> for tipsE<amp>tricks.
344
345 =head1 AUTHOR
346
347 Program by Tobias Oetiker E<lt>oetiker@ee.ethz.chE<gt>
348
349 This manual page by Alex van den Bogaerdt E<lt>alex@ergens.op.het.netE<gt>