make sure argument descriptions comply with Bold = fixed and Italics = variable
[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.
30 Currently this makes no difference but in a future version
31 of rrdtool you may want to collect these values before consolidation.
32
33 The data fetched from the B<RRA> is then B<consolidated> so that
34 there is exactly one datapoint per pixel in the graph. If you do
35 not take care yourself, B<RRDtool> will expand the range slightly
36 if necessary (in that case the first and/or last pixel may very
37 well become unknown!).
38
39 Sometimes data is not exactly as you would like to display it. For
40 instance, you might be collecting B<bytes> per second but want to
41 display B<bits> per second. This is where the
42 B<L<data calculation|rrdgraph_data/CDEF>> command is designed for.
43 After B<consolidating> the data, a copy is made and this copy is
44 modified using a rather flexible B<L<RPN|rrdgraph_rpn/>> command
45 set.
46
47 When you are done fetching and processing the data, it is time to
48 graph it (or print it).  This ends the B<rrdtool graph> sequence.
49
50 =head1 OPTIONS
51
52 =over 4
53
54 =item filename
55
56 The name and path of the graph to generate. It is recommended to
57 end this in C<.png>, C<.svg> or C<.eps> but B<RRDtool> does not enforce this.
58
59 I<filename> can be 'C<->' to send the image to C<stdout>. In
60 that case, no other output is generated.  
61
62 =item Time range
63
64 [B<-s>|B<--start> I<time>]
65 [B<-e>|B<--end> I<time>]
66 [B<-S>|B<--step> I<seconds>]
67
68 The start and end of what you would like to display, and which
69 B<RRA> the data should come from.  Defaults are: 1 day ago until
70 now, with the best possible resolution. B<Start> and B<end> can 
71 be specified in several formats, see
72 L<AT-STYLE TIME SPECIFICATION|rrdfetch/> and L<rrdgraph_examples>.
73 By default, B<rrdtool graph> calculates the width of one pixel in
74 the time domain and tries to get data from an B<RRA> with that
75 resolution.  With the B<step> option you can alter this behaviour.
76 If you want B<rrdtool graph> to get data at a one-hour resolution
77 from the B<RRD>, set B<step> to 3600.  Note: a step smaller than
78 one pixel will silently be ignored.
79
80 =item Labels
81
82 [B<-t>|B<--title> I<string>]
83 [B<-v>|B<--vertical-label> I<string>]
84
85 A horizontal string at the top of the graph and/or a vertically
86 placed string at the left hand side of the graph.
87
88 =item Size
89
90 [B<-w>|B<--width> I<pixels>]
91 [B<-h>|B<--height> I<pixels>]
92 [B<-j>|B<--only-graph>]
93
94 The width and height of the B<canvas> (the part of the graph with
95 the actual lines and such). Defaults are 400 pixels by 100 pixels.
96
97 If you specify the B<--only-graph> option and set the height E<lt> 32
98 pixels you will get a tiny graph image to use as an icon in a potential
99 overview. All labeling will be stripped off the graph.
100
101 =item Limits
102
103 [B<-u>|B<--upper-limit> I<value>]
104 [B<-l>|B<--lower-limit> I<value>]
105 [B<-r>|B<--rigid>]
106
107 By default the graph will be autoscaling so that it displays the
108 portion of the y-axis that is actually used. You can change this
109 behaviour by setting the limits.  The displayed y-axis will show
110 at least from B<lower-limit> to B<upper-limit>.  Autoscaling will
111 still permit those boundaries to be stretched unless the B<rigid>
112 option is set.
113
114 [B<-A>|B<--alt-autoscale>]
115
116 Sometimes the default algorithm for selecting the y-axis scale is not
117 performing very well.  Normally the scale is selected from a predefined
118 set of ranges and this fails miserably when you need to graph something
119 like C<260 + 0.001 * sin(x)>. This option calculates the minimum and
120 maximum y-axis from the actual minimum and maximum values. Our example
121 would display slightly less than C<260-0.001> to slightly more than
122 C<260+0.001> (Contributed by Sasha Mikheev).
123
124 [B<-M>|B<--alt-autoscale-max>]
125
126 Where C<--alt-autoscale> will modify both the absolute maximum AND minimum
127 values, this option will only affect the maximum value. The minimum
128 value, if not defined on the command line, will be 0. This option can
129 be useful when graphing router traffic when the WAN line uses compression,
130 and thus the throughput may be higher than the WAN line speed.
131
132 [B<-N>|B<--no-gridfit>]
133
134 To avoid anti-aliasing effects gridlines are placed on 
135 integer pixel values. This is by default done by extending 
136 the scale so gridlines happens to be spaced using an 
137 integer number of pixels, and starts on integer pixel value.
138 This might extend the scale too much for some logarithmic scales
139 and for linear scales where B<--alt-autoscale> is needed.
140 Using B<--no-gridfit> disables modification of the scale.
141
142 =item Grid
143
144 =over 4
145
146 =item X-Axis
147
148 [B<-x>|B<--x-grid> I<GTM>B<:>I<GST>B<:>I<MTM>B<:>I<MST>B<:>I<LTM>B<:>I<LST>B<:>I<LPR>B<:>I<LFM>]
149
150 [B<-x>|B<--x-grid> B<none>]
151
152 The x-axis label is quite complex to configure, if you don't have
153 very special needs it is probably best to rely on the autoconfiguration
154 to get this right.  You can specify the string C<none> to skip the grid
155 and labels altogether.
156
157 The grid is defined by specifying a certain amount of time in the I<?TM>
158 positions. You can choose from C<SECOND>, C<MINUTE>, C<HOUR>, C<DAY>,
159 C<WEEK>, C<MONTH> or C<YEAR>. Then you define how many of these should
160 pass between each line or label.  This pair (I<?TM:?ST>) needs to be
161 specified for the base grid (I<G??>), the major grid (I<M??>) and the
162 labels (I<L??>). For the labels you also need to define a precision
163 in I<LPR> and a I<strftime> format string in I<LFM>.  I<LPR> defines
164 where each label will be placed. If it is zero, the label will be
165 placed right under the corresponding line (useful for hours, dates
166 etcetera).  If you specify a number of seconds here the label is
167 centered in this interval (useful for Monday, January etcetera).
168
169 Example: C<--x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X>
170
171 This places grid lines every 10 minutes, major grid lines every hour
172 and labels every 4 hours. The labels are placed under the major grid
173 lines as they specify exactly that time.
174
175 Example: C<--x-grid HOUR:8:DAY:1:DAY:1:0:%A>
176
177 This places grid lines every 8 hours, major grid lines and labels
178 each day. The labels are placed exactly between two major grid lines
179 as they specify the complete day and not just midnight.
180
181 =item Y-Axis
182
183 [B<-y>|B<--y-grid> I<grid step>B<:>I<label factor>]
184
185 [B<-y>|B<--y-grid> B<none>]
186
187 Y-axis grid lines appear at each I<grid step> interval.  Labels are
188 placed every I<label factor> lines.  You can specify C<-y none> to
189 skip the grid and labels altogether.  The default for this option is
190 to automatically select sensible values.
191
192 [B<-Y>|B<--alt-y-grid>]
193
194 Place Y grid dynamically based on graph Y range. Algorithm ensures
195 that you always have grid, that there are enough but not too many
196 grid lines and the grid is metric. That is grid lines are placed
197 every 1, 2, 5 or 10 units.  (contributed by Sasha Mikheev)
198
199 [B<-o>|B<--logarithmic>]
200
201 Logarithmic y-axis scaling.
202
203 [B<-X>|B<--units-exponent> I<value>]
204
205 This sets the 10**exponent scaling of the y-axis values.  Normally
206 values will be scaled to the appropriate units (k, M, etc.).  However
207 you may wish to display units always in k (Kilo, 10e3) even if the data
208 is in the M (Mega, 10e6) range for instance.  Value should be an
209 integer which is a multiple of 3 between -18 and 18 inclusive.  It is
210 the exponent on the units you which to use.  For example, use 3 to
211 display the y-axis values in k (Kilo, 10e3, thousands), use -6 to
212 display the y-axis values in u (Micro, 10e-6, millionths).  Use a value
213 of 0 to prevent any scaling of the y-axis values.
214
215 This option is very effective at confusing the heck out of the default
216 rrdtool autoscaler and grid painter. If rrdtool detects that it is not
217 successful in labeling the graph under the given circumstances, it will switch
218 to the more robust B<--alt-y-grid> mode.
219
220 [B<-L>|B<--units-length> I<value>]
221
222 How many digits should rrdtool assume the y-axis labels to be ? You may have to use this option
223 to make enough space once you start fideling with the y-axis labeling.
224
225 =back
226
227 =item Miscellaneous
228
229 [B<-z>|B<--lazy>]
230
231 Only generate the graph, if the current graph is out of date or not
232 existent.
233
234 [B<-f>|B<--imginfo> I<printfstr>]
235
236 After the image has been created, the graph function uses printf
237 together with this format string to create output similar to the PRINT
238 function, only that the printf is supplied with the parameters
239 I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag
240 suitable for including the graph into a web page, the command line
241 would look like this:
242
243  --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
244
245 [B<-c>|B<--color> I<COLORTAG>#I<rrggbb>[I<aa>]]
246
247 Override the default colors for the standard elements of the graph. The
248 I<COLORTAG> is one of C<BACK> background, C<CANVAS> for the background of
249 the actual graph, C<SHADEA> for the left and top border, C<SHADEB> for the
250 right and bottom border, C<GRID>, C<MGRID> for the major grid, C<FONT> for
251 the color of the font, C<AXIS> for the axis of the graph and finaly C<ARROW>
252 for the arrow head pointing to the future. Each color is composed out of
253 three hexadecimal numbers specifying its color component (00 is off, FF is
254 maximum) of red, green and blue. Optionally you may add another hexadecimal
255 number specifying the transparency (FF is solid). You may set this option
256 several times to alter multiple defaults.
257
258 A green arrow is made by: C<--color ARROW:00FF00>
259
260 [B<--zoom> I<factor>]
261
262 Zoom the graphics by the given amount ... The factor must be E<gt> 0
263
264 [B<-n>|B<--font> I<FONTTAG>B<:>I<size>B<:>I<font>]
265
266 Lets you customize which font to use for the various text elements on the
267 RRD graphs. C<DEFAULT> sets the default value for all elements C<TITLE>,
268 C<AXIS> for the axis labels, C<UNIT> for the vertical unit label, C<LEGEND>
269 for the graph legend.
270
271 Use Times for the title: C<--font TITLE:13:/usr/lib/fonts/times.ttf>
272
273 RRDtool comes with a preset default font. You can set the environment
274 variable C<RRD_DEFAULT_FONT> if you want to change this.
275
276 Truetype fonts are only supported for PNG output. See below.
277
278 [B<-a>|B<--imgformat> B<PNG>|B<SVG>|B<EPS>|B<PDF>]
279
280 Image format for the generated graph. For the vector formats you can choose among the standard Postscript fonts
281 Courier-Bold, Courier-BoldOblique, Courier-Oblique, Courier, Helvetica-Bold,
282 Helvetica-BoldOblique, Helvetica-Oblique, Helvetica, Symbol, Times-Bold, Times-BoldItalic,
283 Times-Italic, Times-Roman, ZapfDingbats 
284
285 [B<-i>|B<--interlaced>]
286
287 If images are interlaced they become visible on browsers more quickly.
288
289 [B<-g>|B<--no-legend>]
290
291 Suppress generation of legend; only render the graph.
292
293 [B<-F>|B<--force-rules-legend>]
294
295 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).
296
297 [B<-T>|B<--tabwidth> I<value>]
298
299 By default the tab-width is 40 pixels, use this option to change it.
300
301 [B<-b>|B<--base> I<value>]
302
303 If you are graphing memory (and NOT network traffic) this switch
304 should be set to 1024 so that one Kb is 1024 byte. For traffic
305 measurement, 1 kb/s is 1000 b/s.
306
307 =item Data and variables
308
309 B<DEF:>I<vname>B<=>I<rrdfile>B<:>I<ds-name>B<:>I<CF>[B<:step=>I<step>][B<:start=>I<time>][B<:end=>I<time>]
310
311 B<CDEF:>I<vname>B<=>I<RPN expression>
312
313 B<VDEF:>I<vname>B<=>I<RPN expression>
314
315 You need at least one B<DEF> statement to generate anything. The
316 other statements are useful but optional.
317 See L<rrdgraph_data> and L<rrdgraph_rpn> for exact format.
318
319 =item Graph and print elements
320
321 You need at least one graph element to generate an image and/or
322 at least one print statement to generate a report.
323 See L<rrdgraph_graph> for exact format.
324
325 =back
326
327 =include see_also