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