* fore-rules-legend option -- author name missing
[rrdtool.git] / doc / rrdgraph.src
1 =include name
2
3 =head1 SYNOPSIS
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 present 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|--height E<lt>pixelsE<gt>]>
106 B<[-j|--only-graph]>
107
108 The width and height of the B<canvas> (the part of the graph with
109 the actual lines and such). Defaults are 400 pixels by 100 pixels.
110
111 If you specify the B<--only-graph> and set the height < 32 pixels you will
112 get a tiny graph image to use as an icon in a potential overview. All
113 labeling will be stripped off the graph.
114
115 Z<>
116
117 =item Limits
118
119 I<Old behaviour, until the new options are implemented>
120 B<[-u|--upper-limit E<lt>valueE<gt>]>
121 B<[-l|--lower-limit E<lt>valueE<gt>]>
122 B<[-r|--rigid]>
123
124 By default the graph will be autoscaling so that it displays the
125 portion of the y-axis that is actually used. You can change this
126 behaviour by setting the limits.  The displayed y-axis will show
127 at least from B<lower-limit> to B<upper-limit>.  Autoscaling will
128 still permit those boundaries to be stretched unless the B<rigid>
129 option is set.
130
131 I<New behaviour, after the new options are implemented>
132 B<[--maximum-upper-limit E<lt>valueE<gt>]>
133 B<[--minimum-upper-limit E<lt>valueE<gt>]>
134 B<[--maximum-lower-limit E<lt>valueE<gt>]>
135 B<[--minimum-lower-limit E<lt>valueE<gt>]>
136
137 By default the graph will be autoscaling so that it displays the
138 portion of the y-axis that is actually used. You can change this
139 behaviour by setting the limits.  The displayed y-axis will show
140 at most B<maximum-upper-limit> and at least B<minimum-upper-limit>
141 at the top, and similarly at least B<maximum-lower-limit> and
142 at most B<minimum-lower-limit> at the bottom.  The default is to
143 display at most B<infinity> (so: no limit) and at least
144 B<negative infinity> (no minimal value) at the top. The bottom of
145 the graph has similar defaults. Note that the minimum lower limit
146 is the lowest one so you should compare this with maximum upper
147 limit when you try to figure out what you should set.
148
149 To make sure the graph shows the range of I<-1000> to I<2000>,
150 optionally expanding to no more than I<-3000> to I<4000>,
151 set the following options:
152
153 --maximum-upper-limit 4000 --minimum-upper-limit 2000
154 --maximum-lower-limit -1000 --minimum-lower-limit -3000
155
156 To mimic the old B<rigid> option, you can do:
157
158 --maximum-upper-limit 4000 --minimum-upper-limit 4000
159 --maximum-lower-limit -3000 --minimum-lower-limit -3000
160
161 B<[-A|--alt-autoscale]>
162
163 Sometimes the default algorithm for selecting the y-axis scale is not
164 performing very well.  Normally the scale is selected from a predefined
165 set of ranges and this fails miserably when you need to graph something
166 like C<260 + 0.001 * sin(x)>. This option calculates the minimum and
167 maximum y-axis from the actual minimum and maximum values. Our example
168 would display slightly less than C<260-0.001> to slightly more than
169 C<260+0.001> (Contributed by Sasha Mikheev).
170
171 B<[-M|--alt-autoscale-max]>
172
173 Where C<--alt-autoscale> will modify both the absolute maximum AND minimum
174 values, this option will only affect the maximum value. The minimum
175 value, if not defined on the command line, will be 0. This option can
176 be useful when graphing router traffic when the WAN line uses compression,
177 and thus the throughput may be higher than the WAN line speed.
178
179 B<[-N|--no-gridfit]>
180
181 To avoid anti-aliasing effects gridlines are placed on 
182 integer pixel values. This is by default done by extending 
183 the scale so gridlines happens to be spaced using an 
184 integer number of pixels, and starts on integer pixel value.
185 This might extend the scale too much for some logarithmic scales
186 and for linear scales where --alt-autoscale is needed.
187 Using --no-gridfit disables modification of the scale,
188 and just truncates y-coordinates to integer values for bitmap
189 formats.
190
191 Z<>
192
193 =item Grid
194
195 =over 4
196
197 =item X-Axis
198
199 B<[-x|--x-grid E<lt>I<GTMC<:>GSTC<:>MTMC<:>MSTC<:>LTMC<:>LSTC<:>LPRC<:>LFM>E<gt>]>
200
201 B<[-x|--x-grid C<none>]>
202
203 The x-axis label is quite complex to configure, if you don't have
204 very special needs it is probably best to rely on the autoconfiguration
205 to get this right.  You can specify the string C<none> to skip the grid
206 and labels altogether.
207
208 The grid is defined by specifying a certain amount of time in the I<?TM>
209 positions. You can choose from C<SECOND>, C<MINUTE>, C<HOUR>, C<DAY>,
210 C<WEEK>, C<MONTH> or C<YEAR>. Then you define how many of these should
211 pass between each line or label.  This pair (I<?TM:?ST>) needs to be
212 specified for the base grid (I<G??>), the major grid (I<M??>) and the
213 labels (I<L??>). For the labels you also need to define a precision
214 in I<LPR> and a I<strftime> format string in I<LFM>.  I<LPR> defines
215 where each label will be placed. If it is zero, the label will be
216 placed right under the corresponding line (useful for hours, dates
217 etcetera).  If you specify a number of seconds here the label is
218 centered in this interval (useful for Monday, January etcetera).
219
220 Example: C<--x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X>
221
222 This places grid lines every 10 minutes, major grid lines every hour
223 and labels every 4 hours. The labels are placed under the major grid
224 lines as they specify exactly that time.
225
226 Example: C<--x-grid HOUR:8:DAY:1:DAY:1:0:%A>
227
228 This places grid lines every 8 hours, major grid lines and labels
229 each day. The labels are placed exactly between two major grid lines
230 as they specify the complete day and not just midnight.
231
232 Z<>
233
234 =item Y-Axis
235
236 B<[-y|--y-grid I<E<lt>grid stepE<gt>:E<lt>label factorE<gt>>]>
237
238 B<[-y|--y-grid C<none>]>
239
240 Y-axis grid lines appear at each I<grid step> interval.  Labels are
241 placed every I<label factor> lines.  You can specify C<-y none> to
242 skip the grid and labels altogether.  The default for this option is
243 to automatically select sensible values.
244
245 B<[-Y|--alt-y-grid]>
246
247 Place Y grid dynamically based on graph Y range. Algorithm ensures
248 that you always have grid, that there are enough but not too many
249 grid lines and the grid is metric. That is grid lines are placed
250 every 1, 2, 5 or 10 units.  (contributed by Sasha Mikheev)
251
252 B<[-o|--logarithmic]>
253
254 Logarithmic y-axis scaling.
255
256 B<[-X|--units-exponent E<lt>valueE<gt>]>
257
258 This sets the 10**exponent scaling of the y-axis values.  Normally
259 values will be scaled to the appropriate units (k, M, etc.).  However
260 you may wish to display units always in k (Kilo, 10e3) even if the data
261 is in the M (Mega, 10e6) range for instance.  Value should be an
262 integer which is a multiple of 3 between -18 and 18 inclusive.  It is
263 the exponent on the units you which to use.  For example, use 3 to
264 display the y-axis values in k (Kilo, 10e3, thousands), use -6 to
265 display the y-axis values in u (Micro, 10e-6, millionths).  Use a value
266 of 0 to prevent any scaling of the y-axis values.
267
268 Z<>
269
270 =back
271
272 Z<>
273
274 =item Miscellaneous
275
276 B<[-z|--lazy]>
277
278 Only generate the graph, if the current graph is out of date or not
279 existent.
280
281 B<[-f|--imginfo E<lt>printfstrE<gt>]>
282
283 After the image has been created, the graph function uses printf
284 together with this format string to create output similar to the PRINT
285 function, only that the printf is supplied with the parameters
286 I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag
287 suitable for including the graph into a web page, the command line
288 would look like this:
289
290     --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
291
292 B<[-c|--color I<COLORTAG>#I<rrggbb>[I<aa>]]>
293
294 Override the default colors for the standard elements of the graph.
295 The I<COLORTAG> is one of C<BACK> ground, C<CANVAS>, C<SHADEA> for the
296 left and top border, C<SHADEB> for the right and bottom border, C<GRID>,
297 C<MGRID> for the major grid, C<FONT>, C<FRAME> and axis, C<ARROW>.
298 Each color is composed out of three hexadecimal numbers specifying
299 its color component (00 is off, FF is maximum) of red, green and blue.
300 Optionally you may add another hexadecimal number specifying the
301 transparency (FF is solid).
302 You may set this option several times to alter multiple defaults.
303
304 A green arrow is made by: C<--color ARROW:00FF00>
305
306 B<[--zoom I<factor>]>
307
308 Zoom the graphics by the given amount ... The factor must be E<gt> 0
309
310 B<[-n|--font I<FONTTAG>B<:>I<size>B<:>I<font>]>
311
312 Lets you customize which font to use for the various text elements on the
313 RRD graphs. C<DEFAULT> sets the default value for all elements C<TITLE>,
314 C<AXIS> for the axis labels, C<UNIT> for the vertical unit label, C<LEGEND>
315 for the graph legend.
316
317 Use Times for the title: C<--font TITLE:13:/usr/lib/fonts/times.ttf>
318
319 B<[-a|--imgformat C<PNG>|C<SVG>|C<EPS>|C<PDF>]>
320
321 Image format for the generated graph.
322
323 B<[-i|--interlaced]>
324
325 If images are interlaced they become visible on browsers more quickly.
326
327 B<[-g|--no-legend]>
328
329 Suppress generation of legend; only render the graph.
330
331 B<[-F|--force-rules-legend]>
332
333 Force the generation of HRULE and VRULE legend even if those HRULE or VRULE will not be drawn because out of graph boundaries (mimics behaviour of pre 1.0.42 versions).
334
335 B<[-b|--base E<lt>valueE<gt>]>
336
337 If you are graphing memory (and NOT network traffic) this switch
338 should be set to 1024 so that one Kb is 1024 byte. For traffic
339 measurement, 1 kb/s is 1000 b/s.
340
341 Z<>
342
343 =item Data and variables
344
345 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>>]
346
347 B<CDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
348
349 B<VDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
350
351 You need at least one B<DEF> statement to generate anything. The
352 other statements are useful but optional.
353 See L<rrdgraph_data> and L<rrdgraph_rpn> for exact format.
354
355 Z<>
356
357 =item Graph and print elements
358
359 You need at least one graph element to generate an image and/or
360 at least one print statement to generate a report.
361 See L<rrdgraph_graph> for exact format.
362
363 =back
364
365 =include see_also