Code

Better positioning of the pie when it is alone on the canvas
[rrdtool.git] / doc / rrdgraph.src
1 =include name
3 =head1 SYNOPSYS
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> ...]
14 =head1 DESCRIPTION
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.
21 =head1 OVERVIEW
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).
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)>
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!).
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!
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.
54 =head1 OPTIONS
56 It is expected that most options will move to the graph definition
57 statements (after all, most of them do define graph elements...).
59 =over 4
61 =item filename
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.
66 I<filename> can be 'C<->' to send the image to C<stdout>. In
67 that case, no other output is generated.  
69 Z<>
71 =item Time range
73 B<[-s|--start E<lt>timeE<gt>]>
74 B<[-e|--end E<lt>timeE<gt>]>
75 B<[--step E<lt>secondsE<gt>]>
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.
89 Z<>
91 =item Labels
93 B<[-t|--title E<lt>stringE<gt>]>
94 B<[-v|--vertical-label E<lt>stringE<gt>]>
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.
101 Z<>
103 =item Size
105 B<[-w|--width E<lt>pixelsE<gt>]>
106 B<[-h|--heigth E<lt>pixelsE<gt>]>
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.
111 Z<>
113 =item Limits
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]>
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.
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>]>
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.
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:
149 --maximum-upper-limit 4000 --minimum-upper-limit 2000
150 --maximum-lower-limit -1000 --minimum-lower-limit -3000
152 To mimic the old B<rigid> option, you can do:
154 --maximum-upper-limit 4000 --minimum-upper-limit 4000
155 --maximum-lower-limit -3000 --minimum-lower-limit -3000
157 B<[--alt-autoscale]>
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).
167 B<[--alt-autoscale-max]>
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.
175 Z<>
177 =item Grid
179 =over 4
181 =item X-Axis
183 B<[-x|--x-grid E<lt>I<GTMC<:>GSTC<:>MTMC<:>MSTC<:>LTMC<:>LSTC<:>LPRC<:>LFM>E<gt>]>
185 B<[-x|--x-grid C<none>]>
187 The x-axis label is quite complex to configure, if you don't have
188 very special needs it is probably best to rely on the autoconfiguration
189 to get this right.  You can specify the string C<none> to skip the grid
190 and labels altogether.
192 The grid is defined by specifying a certain amount of time in the I<?TM>
193 positions. You can choose from C<SECOND>, C<MINUTE>, C<HOUR>, C<DAY>,
194 C<WEEK>, C<MONTH> or C<YEAR>. Then you define how many of these should
195 pass between each line or label.  This pair (I<?TM:?ST>) needs to be
196 specified for the base grid (I<G??>), the major grid (I<M??>) and the
197 labels (I<L??>). For the labels you also need to define a precision
198 in I<LPR> and a I<strftime> format string in I<LFM>.  I<LPR> defines
199 where each label will be placed. If it is zero, the label will be
200 placed right under the corresponding line (useful for hours, dates
201 etcetera).  If you specify a number of seconds here the label is
202 centered in this interval (useful for monday, januari etcetera).
204 Example: C<--x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X>
206 This places grid lines every 10 minutes, major grid lines every hour
207 and labels every 4 hours. The labels are placed under the major grid
208 lines as they specify exactly that time.
210 Example: C<--x-grid HOUR:8:DAY:1:DAY:1:0:%A>
212 This places grid lines every 8 hours, major grid lines and labels
213 each day. The labels are placed exactly between two major grid lines
214 as they specify the complete day and not just midnight.
216 Z<>
218 =item Y-Axis
220 B<[-y|--y-grid I<E<lt>grid stepE<gt>:E<lt>label factorE<gt>>]>
222 B<[-y|--y-grid C<none>]>
224 Y-axis grid lines appear at each I<grid step> interval.  Labels are
225 placed every I<label factor> lines.  You can specify C<-y none> to
226 skip the grid and labels altogether.  The default for this option is
227 to automatically select sensible values.
229 B<[--alt-y-grid]>
231 Place Y grid dynamically based on graph Y range. Algorithm ensures
232 that you always have grid, that there are enough but not too many
233 grid lines and the grid is metric. That is grid lines are placed
234 every 1, 2, 5 or 10 units.  (contributed by Sasha Mikheev)
236 B<[-o|--logarithmic]>
238 Logarithmic y-axis scaling.
240 B<[--units-exponent E<lt>valueE<gt>]>
242 This sets the 10**exponent scaling of the y-axis values.  Normally
243 values will be scaled to the appropriate units (k, M, etc.).  However
244 you may wish to display units always in k (Kilo, 10e3) even if the data
245 is in the M (Mega, 10e6) range for instance.  Value should be an
246 integer which is a multiple of 3 between -18 and 18 inclusive.  It is
247 the exponent on the units you which to use.  For example, use 3 to
248 display the y-axis values in k (Kilo, 10e3, thousands), use -6 to
249 display the y-axis values in u (Micro, 10e-6, millionths).  Use a value
250 of 0 to prevent any scaling of the y-axis values.
252 Z<>
254 =back
256 Z<>
258 =item Miscellaneous
260 B<[-z|--lazy]>
262 Only generate the graph, if the current graph is out of date or not
263 existent.
265 B<[-f|--imginfo E<lt>printfstrE<gt>]>
267 After the image has been created, the graph function uses printf
268 together with this format string to create output similar to the PRINT
269 function, only that the printf is supplied with the parameters
270 I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag
271 suitable for including the graph into a web page, the command line
272 would look like this:
274     --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
276 B<[-c|--color I<COLORTAG>#I<rrggbb>[I<aa>]]>
278 Override the default colors for the standard elements of the graph.
279 The I<COLORTAG> is one of C<BACK> ground, C<CANVAS>, C<SHADEA> for the
280 left and top border, C<SHADEB> for the right and bottom border, C<GRID>,
281 C<MGRID> for the major grid, C<FONT>, C<FRAME> and axis, C<ARROW>.
282 Each color is composed out of three hexadecimal numbers specifying
283 its color component (00 is off, FF is maximum) of red, green and blue.
284 Optionally you may add another hexademimal number specifying the
285 transparency (FF is solid).
286 You may set this option several times to alter multiple defaults.
288 A green arrow is made by: C<--color ARROW:00FF00>
290 B<[--zoom I<factor>]>
292 Zoom the graphics by the given amount ... The factor must be E<gt> 0
294 B<[-n|--font I<FONTTAG>B<:>I<size>B<:>I<font>]>
296 Lets you customize which font to use for the various text elements on the
297 rrd graphs. C<DEFAULT> sets the default value for all elements C<TITLE>,
298 C<AXIS> for the axis labels, C<UNIT> for the vertical unit label, C<LEGEND>
299 for the graph legend.
301 Use Times for the title: C<--font TITLE:13:/usr/lib/fonts/times.ttf>
303 B<[-a|--imgformat C<PNG>]>
305 At present only PNG is supported, but C<EPS>, C<SVG> or even C<FLASH> should
306 not be all that difficult to add.
308 B<[-i|--interlaced]>
310 If images are interlaced they become visible on browsers more quickly.
312 B<[-g|--no-legend]>
314 Suppress generation of legend; only render the graph.
316 B<[-b|--base E<lt>valueE<gt>]>
318 If you are graphing memory (and NOT network traffic) this switch
319 should be set to 1024 so that one Kb is 1024 byte. For traffic
320 measurement, 1 kb/s is 1000 b/s.
322 Z<>
324 =item Data and variables
326 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>>]]
328 B<CDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
330 B<VDEF:>I<E<lt>vnameE<gt>>=I<E<lt>RPN expressionE<gt>>
332 You need at least one B<DEF> statement to generate anything. The
333 other statements are useful but optional.
334 See L<rrdgraph_data> and L<rrdgraph_rpn> for exact format.
336 Z<>
338 =item Graph and print elements
340 You need at least one graph element to generate an image and/or
341 at least one print statement to generate a report.
342 See L<rrdgraph_graph> for exact format.
344 =back
346 =include see_also