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