X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=doc%2Frrdgraph.pod;h=57359ac66972b176f1f253067e8711a376030f22;hp=2e3a4f6470aa4a7d920c1aa23171253fc514ebf0;hb=07de871981951c5ff711ae94ce2c69f0423c3987;hpb=5837606887a6d81e8b1f7588525cb1c8783fb62b diff --git a/doc/rrdgraph.pod b/doc/rrdgraph.pod index 2e3a4f6..57359ac 100644 --- a/doc/rrdgraph.pod +++ b/doc/rrdgraph.pod @@ -1,596 +1,540 @@ =head1 NAME -rrdtool graph - Create a graph based on data from one or several RRD - -=for html
PDF version.
+rrdgraph - Round Robin Database tool grapher functions =head1 SYNOPSIS -B B I -S<[B<-s>|B<--start> I]> -S<[B<-e>|B<--end> I]> -S<[B<-x>|B<--x-grid> I]> -S<[B<-y>|B<--y-grid> I]> -S<[B<--alt-y-grid>]> -S<[B<--alt-autoscale>]> -S<[B<--alt-autoscale-max>]> -S<[B<--units-exponent>]> I]> -S<[B<-v>|B<--vertical-label> I]> -S<[B<-w>|B<--width> I]> -S<[B<-h>|B<--height> I]> -S<[B<-i>|B<--interlaced>]> -S<[B<-f>|B<--imginfo> I]> -S<[B<-a>|B<--imgformat> B|B]> -S<[B<-z>|B<--lazy>]> -S<[B<-o>|B<--logarithmic>]> -S<[B<-u>|B<--upper-limit> I]> -S<[B<-l>|B<--lower-limit> I]> -S<[B<-g>|B<--no-legend>]> -S<[B<-r>|B<--rigid>]> -S<[B<--step> I]> -S<[B<-b>|B<--base> I]> -S<[B<-c>|B<--color> IB<#>I]> -S<[B<-t>|B<--title> I]> -S<[B<DEF:>I<vname>B<=>I<rrd>B<:>I<ds-name>B<:>I<CF>]> -S<[B<CDEF:>I<vname>B<=>I<rpn-expression>]> -S<[B<PRINT:>I<vname>B<:>I<CF>B<:>I<format>]> -S<[B<GPRINT:>I<vname>B<:>I<CF>B<:>I<format>]> -S<[B<COMMENT:>I<text>]> -S<[B<HRULE:>I<value>B<#>I<rrggbb>[B<:>I<legend>]]> -S<[B<VRULE:>I<time>B<#>I<rrggbb>[B<:>I<legend>]]> -S<[B<LINE>{B<1>|B<2>|B<3>}B<:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]> -S<[B<AREA:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]> -S<[B<STACK:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]]]> +B<rrdtool graph|graphv> I<filename> +[I<L<option|rrdgraph/OPTIONS>> ...] +[I<L<data definition|rrdgraph_data/DEF>> ...] +[I<L<data calculation|rrdgraph_data/CDEF>> ...] +[I<L<variable definition|rrdgraph_data/VDEF>> ...] +[I<L<graph element|rrdgraph_graph/GRAPH>> ...] +[I<L<print element|rrdgraph_graph/PRINT>> ...] =head1 DESCRIPTION -The B<graph> functions main purpose is to create graphical -representations of the data stored in one or several B<RRD>s. Apart -from generating graphs, it can also extract numerical reports. +The B<graph> function of B<RRDtool> is used to present the +data from an B<RRD> to a human viewer. Its main purpose is to +create a nice graphical representation, but it can also generate +a numerical report. + +=head1 OVERVIEW + +B<rrdtool graph> needs data to work with, so you must use one or more +B<L<data definition|rrdgraph_data/DEF>> statements to collect this +data. You are not limited to one database, it's perfectly legal to +collect data from two or more databases (one per statement, though). + +If you want to display averages, maxima, percentiles, etcetera +it is best to collect them now using the +B<L<variable definition|rrdgraph_data/VDEF>> statement. +Currently this makes no difference, but in a future version +of rrdtool you may want to collect these values before consolidation. -=over +The data fetched from the B<RRA> is then B<consolidated> so that +there is exactly one datapoint per pixel in the graph. If you do +not take care yourself, B<RRDtool> will expand the range slightly +if necessary. Note, in that case the first and/or last pixel may very +well become unknown! -=item I<filename> +Sometimes data is not exactly in the format you would like to display +it. For instance, you might be collecting B<bytes> per second, but +want to display B<bits> per second. This is what the B<L<data +calculation|rrdgraph_data/CDEF>> command is designed for. After +B<consolidating> the data, a copy is made and this copy is modified +using a rather powerful B<L<RPN|rrdgraph_rpn>> command set. -The name of the graph to generate. Since B<rrdtool> outputs -GIFs and PNGs, it's recommended that the filename end in either -F<.gif> or F<.png>. B<rrdtool> does not enforce this, however. -If the I<filename> is set to '-' the image file will be written -to standard out. All other output will get suppressed. +When you are done fetching and processing the data, it is time to +graph it (or print it). This ends the B<rrdtool graph> sequence. -PNG output is recommended, since it takes up to 40% less disk space -and 20-30% less time to generate than a GIF file. +Use B<graphv> instead of B<graph> to get detailed information about the +graph geometry and data once it is drawn. See the bottom of the document for +more information. -If no graph functions are called, the graph will not be created. +=head1 OPTIONS -=item B<-s>|B<--start> I<seconds> (default end-1day) -The time when the graph should begin. Time in seconds since -epoch (1970-01-01) is required. Negative numbers are relative to the -current time. By default one day worth of data will be graphed. -See also AT-STYLE TIME SPECIFICATION section in the I<rrdfetch> -documentation for a detailed explanation on how to specify time. -=item B<-e>|B<--end> I<seconds> (default now) +=head2 I<filename> -The time when the graph should end. Time in seconds since epoch. -See also AT-STYLE TIME SPECIFICATION section in the I<rrdfetch> -documentation for a detailed explanation of ways to specify time. +The name and path of the graph to generate. It is recommended to +end this in C<.png>, C<.svg> or C<.eps>, but B<RRDtool> does not enforce this. -=item B<-x>|B<--x-grid> I<x-axis grid and label> (default autoconfigure) +I<filename> can be 'C<->' to send the image to C<stdout>. In +this case, no other output is generated. -The x-axis label is quite complex to configure. So if you don't have -very special needs, you can rely on the autoconfiguration to get this -right. +=head2 Time range -If you want no x-grid at all, use the magic setting B<none>. +[B<-s>|B<--start> I<time>] +[B<-e>|B<--end> I<time>] +[B<-S>|B<--step> I<seconds>] -The x-axis label and grid can be configured, using the following format: +The start and end of the time series you would like to display, and which +B<RRA> the data should come from. Defaults are: 1 day ago until +now, with the best possible resolution. B<Start> and B<end> can +be specified in several formats, see +L<AT-STYLE TIME SPECIFICATION|rrdfetch> and L<rrdgraph_examples>. +By default, B<rrdtool graph> calculates the width of one pixel in +the time domain and tries to get data from an B<RRA> with that +resolution. With the B<step> option you can alter this behaviour. +If you want B<rrdtool graph> to get data at a one-hour resolution +from the B<RRD>, set B<step> to 3'600. Note: a step smaller than +one pixel will silently be ignored. -I<GTM>B<:>I<GST>B<:>I<MTM>B<:>I<MST>B<:>I<LTM>:I<LST>B<:>I<LPR>B<:>I<LFM> +=head2 Labels -You have to configure three elements making up the x-axis labels and -grid. The base grid (I<G??>), the major grid (I<M??>) and the labels -(I<L??>). The configuration is based on the idea that you first -specify a well known amount of time (I<?TM>) and then say how many -times it has to pass between each grid line or label (I<?ST>). For the -label you have to define two additional items: The precision of the -label in seconds (I<LPR>) and the strftime format used to generate the -text of the label (I<LFM>). +[B<-t>|B<--title> I<string>] +[B<-v>|B<--vertical-label> I<string>] -The I<?TM> elements must be one of the following keywords: B<SECOND>, -B<MINUTE>, B<HOUR>, B<DAY>, B<WEEK>, B<MONTH> or B<YEAR>. +A horizontal string at the top of the graph and/or a vertically +placed string at the left hand side of the graph. -If you wanted a graph with a base grid every 10 minutes and a major -one every hour, with labels every hour you would use the following -x-axis definition. -C<MINUTE:10:HOUR:1:HOUR:1:0:%X> +=head2 Size -The precision in this example is 0 because the %X format is exact. If -the label was the name of the day, we would have had a precision of 24 -hours, because when you say something like 'Monday' you mean the whole -day and not Monday morning 00:00. Thus the label should be positioned -at noon. By defining a precision of 24 hours or rather 86400 seconds, -you make sure that this happens. +[B<-w>|B<--width> I<pixels>] +[B<-h>|B<--height> I<pixels>] +[B<-j>|B<--only-graph>] +[B<-D>|B<--full-size-mode>] -=item B<-y>|B<--y-grid> I<grid step>:I<label factor> (default autoconfigure) +By default, the width and height of the B<canvas> (the part with +the actual data and such). This defaults to 400 pixels by 100 pixels. -Makes vertical grid lines appear at I<grid step> interval. Every -I<label factor> gridstep, a major grid line is printed, along with -label showing the value of the grid line. +If you specify the B<--full-size-mode> option, the width and height +specify the final dimensions of the output image and the canvas +is automatically resized to fit. -If you want no y-grid at all set specify the magic word B<none>. +If you specify the B<--only-graph> option and set the height E<lt> 32 +pixels you will get a tiny graph image (thumbnail) to use as an icon +for use in an overview, for example. All labeling will be stripped off +the graph. -=item B<--alt-y-grid> +=head2 Limits -Place Y grid dynamically based on graph Y range. Algorithm ensures -that you always have grid, that there are enough but not too many -grid lines and the grid is metric. That is grid lines are placed -every 1, 2, 5 or 10 units. (contributed by Sasha Mikheev) +[B<-u>|B<--upper-limit> I<value>] +[B<-l>|B<--lower-limit> I<value>] +[B<-r>|B<--rigid>] +By default the graph will be autoscaling so that it will adjust the +y-axis to the range of the data. You can change this behaviour by +explicitly setting the limits. The displayed y-axis will then range at +least from B<lower-limit> to B<upper-limit>. Autoscaling will still +permit those boundaries to be stretched unless the B<rigid> option is +set. -=item B<--alt-autoscale> +[B<-A>|B<--alt-autoscale>] -Compute Y range based on function absolute minimum and -maximum values. Default algorithm uses predefined set of ranges. -This is good in many cases but it fails miserably when you need -to graph something like 260 + 0.001 * sin(x). Default algorithm -will use Y range from 250 to 300 and on the graph you will see -almost straight line. With --alt-autoscale Y range will be -from slightly less the 260 - 0.001 to slightly more then 260 + 0.001 -and periodic behavior will be seen. (contributed by Sasha Mikheev) +Sometimes the default algorithm for selecting the y-axis scale is not +satisfactory. Normally the scale is selected from a predefined +set of ranges and this fails miserably when you need to graph something +like C<260 + 0.001 * sin(x)>. This option calculates the minimum and +maximum y-axis from the actual minimum and maximum data values. Our example +would display slightly less than C<260-0.001> to slightly more than +C<260+0.001> (this feature was contributed by Sasha Mikheev). -=item B<--alt-autoscale-max> +[B<-J>|B<--alt-autoscale-min>] -Where --alt-autoscale will modify both the absolute maximum AND minimum -values, this option will only affect the maximum value. The minimum +Where C<--alt-autoscale> will modify both the absolute maximum AND minimum +values, this option will only affect the minimum value. The maximum value, if not defined on the command line, will be 0. This option can be useful when graphing router traffic when the WAN line uses compression, and thus the throughput may be higher than the WAN line speed. -=item B<--units-exponent> I<value> (default autoconfigure) +[B<-M>|B<--alt-autoscale-max>] -This sets the 10**exponent scaling of the y-axis values. Normally -values will be scaled to the appropriate units (k, M, etc.). However -you may wish to display units always in k (Kilo, 10e3) even if the data -is in the M (Mega, 10e6) range for instance. Value should be an -integer which is a multiple of 3 between -18 and 18 inclusive. It is -the exponent on the units you which to use. For example, use 3 to -display the y-axis values in k (Kilo, 10e3, thousands), use -6 to -display the y-axis values in u (Micro, 10e-6, millionths). Use a value -of 0 to prevent any scaling of the y-axis values. +Where C<--alt-autoscale> will modify both the absolute maximum AND minimum +values, this option will only affect the maximum value. The minimum +value, if not defined on the command line, will be 0. This option can +be useful when graphing router traffic when the WAN line uses compression, +and thus the throughput may be higher than the WAN line speed. -=item B<-v>|B<--vertical-label> I<text> +[B<-N>|B<--no-gridfit>] -vertical label on the left side of the graph. This is normally used to -specify the units used. +In order to avoid anti-aliasing blurring effects rrdtool snaps +points to device resolution pixels, this results in a crisper +appearance. If this is not to your liking, you can use this switch +to turn this behaviour off. -=item B<-w>|B<--width> I<pixels> (default 400 pixel) +Gridfitting is turned off for PDF, EPS, SVG output by default. -Width of the drawing area within the graph. This affects the size of the -gif. +=head2 X-Axis -=item B<-h>|B<--height> I<pixels> (default 100 pixel) +[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>] -Width of the drawing area within the graph. This affects the size of the -gif. +[B<-x>|B<--x-grid> B<none>] -=item B<-i>|B<--interlaced> (default: false) +The x-axis label is quite complex to configure. If you don't have +very special needs it is probably best to rely on the autoconfiguration +to get this right. You can specify the string C<none> to suppress the grid +and labels altogether. -If you set this option, then the resulting GIF will be interlaced. -Most web browsers display these incrementally as they load. If -you do not use this option, the GIFs default to being progressive -scanned. The only effect of this option is to control the format -of the GIF on disk. It makes no changes to the layout or contents -of the graph. +The grid is defined by specifying a certain amount of time in the I<?TM> +positions. You can choose from C<SECOND>, C<MINUTE>, C<HOUR>, C<DAY>, +C<WEEK>, C<MONTH> or C<YEAR>. Then you define how many of these should +pass between each line or label. This pair (I<?TM:?ST>) needs to be +specified for the base grid (I<G??>), the major grid (I<M??>) and the +labels (I<L??>). For the labels you also must define a precision +in I<LPR> and a I<strftime> format string in I<LFM>. I<LPR> defines +where each label will be placed. If it is zero, the label will be +placed right under the corresponding line (useful for hours, dates +etcetera). If you specify a number of seconds here the label is +centered on this interval (useful for Monday, January etcetera). -=item B<-f>|B<--imginfo> I<formatstring> + --x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X -After the image has been created, the graph function uses printf -together with this format string to create output similar to the PRINT -function, only that the printf is supplied with the parameters -I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag -suitable for including the graph into a web page, the command line -would look like this: +This places grid lines every 10 minutes, major grid lines every hour, +and labels every 4 hours. The labels are placed under the major grid +lines as they specify exactly that time. - --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">' + --x-grid HOUR:8:DAY:1:DAY:1:86400:%A -=item B<-a>|B<--imgformat> B<GIF>|B<PNG> (default: GIF) +This places grid lines every 8 hours, major grid lines and labels +each day. The labels are placed exactly between two major grid lines +as they specify the complete day and not just midnight. -Allows you to produce PNG output from rrdtool. +=head2 Y-Axis -=item B<-z>|B<--lazy> (default: false) +[B<-y>|B<--y-grid> I<grid step>B<:>I<label factor>] -Only generate the graph, if the current gif is out of date or not -existent. +[B<-y>|B<--y-grid> B<none>] -=item B<-u>|B<--upper-limit> I<value> (default autoconfigure) +Y-axis grid lines appear at each I<grid step> interval. Labels are +placed every I<label factor> lines. You can specify C<-y none> to +suppress the grid and labels altogether. The default for this option is +to automatically select sensible values. -Defines the value normally located at the upper border of the -graph. If the graph contains higher values, the upper border will -move upwards to accomodate these values as well. +If you have set --y-grid to 'none' not only the labels get suppressed, also +the space reserved for the labels is removed. You can still add space +manually if you use the --units-length command to explicitly reserve space. -If you want to define an upper-limit which will not move in any -event you have to set the B<--rigid> option as well. +[B<-Y>|B<--alt-y-grid>] -=item B<-l>|B<--lower-limit> I<value> (default autoconfigure) +Place the Y grid dynamically based on the graph's Y range. The algorithm +ensures that you always have a grid, that there are enough but not too many +grid lines, and that the grid is metric. That is the grid lines are placed +every 1, 2, 5 or 10 units. This parameter will also ensure that you get +enough decimals displayed even if your graph goes from 69.998 to 70.001. +(contributed by Sasha Mikheev). -This is not the lower limit of a graph. But rather, this is the -maximum lower bound of a graph. For example, the value -100 will -result in a graph that has a lower limit of -100 or less. Use this -keyword to expand graphs down. +[B<-o>|B<--logarithmic>] -=item B<-r>|B<--rigid> +Logarithmic y-axis scaling. -rigid boundaries mode. Normally rrdgraph will automatically expand the -lower and upper limit if the graph contains a value outside the valid -range. With the r option you can disable this behavior +[B<-X>|B<--units-exponent> I<value>] -=item B<-b>|B<--base> I<value> +This sets the 10**exponent scaling of the y-axis values. Normally, +values will be scaled to the appropriate units (k, M, etc.). However, +you may wish to display units always in k (Kilo, 10e3) even if the data +is in the M (Mega, 10e6) range, for instance. Value should be an +integer which is a multiple of 3 between -18 and 18 inclusively. It is +the exponent on the units you wish to use. For example, use 3 to +display the y-axis values in k (Kilo, 10e3, thousands), use -6 to +display the y-axis values in u (Micro, 10e-6, millionths). Use a value +of 0 to prevent any scaling of the y-axis values. -if you are graphing memory (and NOT network traffic) this switch -should be set to 1024 so that one Kb is 1024 byte. For traffic -measurement, 1 kb/s is 1000 b/s. +This option is very effective at confusing the heck out of the default +rrdtool autoscaler and grid painter. If rrdtool detects that it is not +successful in labeling the graph under the given circumstances, it will switch +to the more robust B<--alt-y-grid> mode. -=item B<-o>|B<--logarithmic> +[B<-L>|B<--units-length> I<value>] -logarithmic y-axis scaling +How many digits should rrdtool assume the y-axis labels to be? You +may have to use this option to make enough space once you start +fiddling with the y-axis labeling. -=item B<-c>|B<--color> I<COLORTAG>B<#>I<rrggbb> (default colors) +[B<--units=si>] -override the colors for the standard elements of the graph. The I<COLORTAG> -must be one of the following symbolic names: B<BACK> ground, B<CANVAS>, -B<SHADEA> left/top border, B<SHADEB> right/bottom border, B<GRID>, B<MGRID> -major grid, B<FONT>, B<FRAME> and axis of the graph or B<ARROW>. This option -can be called multiple times to set several colors. +With this option y-axis values on logarithmic graphs will be scaled to +the appropriate units (k, M, etc.) instead of using exponential notation. +Note that for linear graphs, SI notation is used by default. -=item B<-g>|B<--no-legend> +=head2 Right Y Axis -Suppress generation of legend; only render the graph. +[B<--right-axis> I<scale>B<:>I<shift>] +[B<--right-axis-label> I<label>] -=item B<-t>|B<--title> I<text> (default no title) +A second axis will be drawn to the right of the graph. It is tied to the +left axis via the scale and shift parameters. You can also define a label +for the right axis. -Define a title to be written into the graph +[B<--right-axis-format> I<format-string>] -=item B<--step> I<value> (default automatic) +By default the format of the axis lables gets determined automatically. If +you want todo this your self, use this option with the same %lf arguments +you know from the PRING and GPRINT commands. -By default rrdgraph calculates the width of one pixle in the time domain and -tries to get data at that resolution from the RRD. With this switch you can -override this behaviour. If you want rrdgraph to get data at 1 hour -resolution from the RRD, then you can set the step to 3600 seconds. Note, -that a step smaller than 1 pixle will be silently ignored. +=head2 Legend -=item B<DEF:>I<vname>B<=>I<rrd>B<:>I<ds-name>B<:>I<CF> +[B<-g>|B<--no-legend>] -Define virtual name for a data source. This name can then be used -in the functions explained below. The -DEF call automatically chooses an B<RRA> which contains I<CF> consolidated data in a -resolution appropriate for the size of the graph to be drawn. Ideally -this means that one data point from the B<RRA> should be represented -by one pixel in the graph. If the resolution of the B<RRA> is higher -than the resolution of the graph, the data in the RRA will be further -consolidated according to the consolidation function (I<CF>) chosen. +Suppress generation of the legend; only render the graph. -=item B<CDEF:>I<vname>B<=>I<rpn-expression> +[B<-F>|B<--force-rules-legend>] -Create a new virtual data source by evaluating a mathematical expression, -specified in Reverse Polish Notation (RPN). If you have ever used a traditional -HP calculator you already know RPN. The idea behind RPN notation is, -that you have a stack and push your data onto this stack. When ever -you execute an operation, it takes as many data values from the stack -as needed. The pushing of data is implicit, so when ever you specify a number -or a variable, it gets pushed automatically. +Force the generation of HRULE and VRULE legends even if those HRULE or +VRULE will not be drawn because out of graph boundaries (mimics +behaviour of pre 1.0.42 versions). -If this is all a big load of incomprehensible words for you, maybe an -example helps (a more complete explanation is given in [1]): The -expression I<vname+3/2> becomes C<vname,3,2,/,+> in RPN. First the three -values get pushed onto the stack (which now contains (the current -value of) vname, a 3 and a 2). Then the / operator pops two values -from the stack (3 and 2), divides the first argument by the second -(3/2) and pushes the result (1.5) back onto the stack. Then the + -operator pops two values (vname and 1.5) from the stack; both values -are added up and the result gets pushes back onto the stack. In the -end there is only one value left on the stack: The result of the -expression. +[B<--legend-position>=(north|south|west|east)] -The I<rpn-expression> in the B<CDEF> function takes both, constant values -as well as I<vname> variables. The following operators can be used on these -values: +Place the legend at the given side of the graph. The default is south. +In west or east position it is necessary to add line breaks manually. -=over +[B<--legend-direction>=(topdown|bottomup)] -=item +, -, *, /, % +Place the legend items in the given vertical order. The default is topdown. +Using bottomup the legend items appear in the same vertical order as a +stack of lines or areas. -pops two values from the stack applies the selected operator and pushes -the result back onto the stack. The % operator stands for the modulo -operation. +=head2 Miscellaneous -=item SIN, COS, LOG, EXP, FLOOR, CEIL +[B<-z>|B<--lazy>] -pops one value from the stack, applies the selected function and pushes -the result back onto the stack. +Only generate the graph if the current graph is out of date or not existent. +Note, that all the calculations will happen regardless so that the output of +PRINT and graphv will be complete regardless. Note that the behaviour of +lazy in this regard has seen several changes over time. The only thing you +can realy rely on before rrdtool 1.3.7 is that lazy will not generate the +graph when it is already there and up to date, and also that it will output +the size of the graph. -=item LT, LE, GT, GE, EQ +[B<--daemon> I<address>] -pops two values from the stack, compares them according to the selected -condition and pushes either 1 back onto the stack if the condition is true -and 0 if the condition was not true. +Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent +to the server before reading the RRD files. This allows the graph to contain +fresh data even if the daemon is configured to cache values for a long time. +For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual. -=item IF + rrdtool graph [...] --daemon unix:/var/run/rrdcached.sock [...] -pops three values from the stack. If the last value is not 0, the -second value will be pushed back onto the stack, otherwise the -first value is pushed back. +[B<-f>|B<--imginfo> I<printfstr>] -If the stack contains the values A, B, C, D, E are presently on the -stack, the IF operator will pop the values E D and C of the stack. It will -look at C and if it is not 0 it will push D back onto the stack, otherwise -E will be sent back to the stack. +After the image has been created, the graph function uses printf +together with this format string to create output similar to the PRINT +function, only that the printf function is supplied with the parameters +I<filename>, I<xsize> and I<ysize>. In order to generate an B<IMG> tag +suitable for including the graph into a web page, the command line +would look like this: -=item MIN, MAX + --imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">' -selects the lesser or larger of the two top stack values respectively +[B<-c>|B<--color> I<COLORTAG>#I<rrggbb>[I<aa>]] -=item LIMIT +Override the default colors for the standard elements of the graph. The +I<COLORTAG> is one of C<BACK> background, C<CANVAS> for the background of +the actual graph, C<SHADEA> for the left and top border, C<SHADEB> for the +right and bottom border, C<GRID>, C<MGRID> for the major grid, C<FONT> for +the color of the font, C<AXIS> for the axis of the graph, C<FRAME> for the +line around the color spots, and finally C<ARROW> for the arrow head pointing +up and forward. Each color is composed out of three hexadecimal numbers +specifying its rgb color component (00 is off, FF is maximum) of red, green +and blue. Optionally you may add another hexadecimal number specifying the +transparency (FF is solid). You may set this option several times to alter +multiple defaults. -replaces the value with I<*UNKNOWN*> if it is outside the limits specified -by the two values above it on the stack. +A green arrow is made by: C<--color ARROW#00FF00> - CDEF:a=alpha,0,100,LIMIT +[B<--zoom> I<factor>] -=item DUP, EXC, POP +Zoom the graphics by the given amount. The factor must be E<gt> 0 -These manipulate the stack directly. DUP will duplicate the top of the -stack, pushing the result back onto the stack. EXC will exchange the top -two elements of the stack, and POP will pop off the top element of the -stack. Having insufficient elements on the stack for these operations is -an error. +[B<-n>|B<--font> I<FONTTAG>B<:>I<size>B<:>[I<font>]] -=item UN +This lets you customize which font to use for the various text elements on +the RRD graphs. C<DEFAULT> sets the default value for all elements, C<TITLE> +for the title, C<AXIS> for the axis labels, C<UNIT> for the vertical unit +label, C<LEGEND> for the graph legend, C<WATERMARK> for the watermark on the +edge of the graph. -Pops one value off the stack, if it is I<*UNKNOWN*>, 1 will be pushed -back otherwise 0. +Use Times for the title: C<--font TITLE:13:Times> -=item UNKN +Note that you need to quote the argument to B<--font> if the font-name +contains whitespace: +--font "TITLE:13:Some Font" -Push an I<*UNKNOWN*> value onto the stack. +If you do not give a font string you can modify just the size of the default font: +C<--font TITLE:13:>. -=item PREV +If you specify the size 0 then you can modify just the font without touching +the size. This is especially useful for altering the default font without +resetting the default fontsizes: C<--font DEFAULT:0:Courier>. -Push I<*UNKNOWN*> if its at the first value of a data set or otherwise -the value of this CDEF at the previous time step. This allows you to -perform calculations across the data. +RRDtool comes with a preset default font. You can set the environment +variable C<RRD_DEFAULT_FONT> if you want to change this. -=item INF, NEGINF +RRDtool uses Pango for its font handling. This means you can to use +the full Pango syntax when selecting your font: -Push a positive or negative infinite (oo) value onto the stack. When -drawing an infinite number it appears right at the top or bottom edge of the -graph, depending whether you have a positive or negative infinite number. +The font name has the form "[I<FAMILY-LIST>] [I<STYLE-OPTIONS>] [I<SIZE>]", +where I<FAMILY-LIST> is a comma separated list of families optionally +terminated by a comma, I<STYLE_OPTIONS> is a whitespace separated list of +words where each WORD describes one of style, variant, weight, stretch, or +gravity, and I<SIZE> is a decimal number (size in points) or optionally +followed by the unit modifier "px" for absolute size. Any one of the options +may be absent. -=item NOW +[B<-R>|B<--font-render-mode> {B<normal>,B<light>,B<mono>}] -Push the current (real world) time onto the stack. +There are 3 font render modes: -=item TIME +B<normal>: Full Hinting and Antialiasing (default) -Push the time the current sample was taken onto the stack. This is the -number of non-skip seconds since 0:00:00 January 1, 1970. +B<light>: Slight Hinting and Antialiasing -=item LTIME +B<mono>: Full Hinting and NO Antialiasing -This is like TIME B<+ current timezone offset in seconds>. The current -offset takes daylight saving time into account, given your OS supports -this. If you were looking at a sample, in Zurich, in summer, the -offset would be 2*3600 seconds, as Zurich at that time of year is 2 -hours ahead of UTC. -Note that the timezone offset is always calculated for the time the -current sample was taken at. It has nuthing todo with the time you are -doing the calculation. +[B<-B>|B<--font-smoothing-threshold> I<size>] -=back +(this gets ignored in 1.3 for now!) -Please note that you may only use I<vname> variables that you -previously defined by either B<DEF> or B<CDEF>. Furthermore, as of -this writing (version 0.99.25), you must use at least one I<vname> -per expression, that is "CDEF:fourtytwo=2,40,+" will yield an error -message but not a I<vname> fourtytwo that's always equal to 42. +This specifies the largest font size which will be rendered +bitmapped, that is, without any font smoothing. By default, +no text is rendered bitmapped. -=item B<PRINT:>I<vname>B<:>I<CF>B<:>I<format> +[B<-P>|B<--pango-markup>] -Calculate the chosen consolidation function I<CF> over the data-source -variable I<vname> and C<printf> the result to stdout using I<format>. -In the I<format> string there should be a '%lf' or '%le' marker in the -place where the number should be printed. +All text in rrdtool is rendered using Pango. With the B<--pango-markup> option, all +text will be processed by pango markup. This allows to embed some simple html +like markup tags using -If an additional '%s' is found AFTER the marker, the value will be scaled -and an appropriate SI magnitude unit will be printed in place of the '%s' -marker. The scaling will take the '--base' argument into consideration! + <span key="value">text</span> -If a '%S' is used instead of a '%s', then instead of calculating the -appropriate SI magnitude unit for this value, the previously calculated -SI magnitude unit will be used. This is useful if you want all the values -in a PRINT statement to have the same SI magnitude unit. If there was -no previous SI magnitude calculation made, then '%S' behaves like a '%s', -unless the value is 0, in which case it does not remember a SI magnitude -unit and a SI magnitude unit will only be calculated when the next '%s' is -seen or the next '%S' for a non-zero value. +Apart from the verbose syntax, there are also the following short tags available. -If you want to put a '%' into your PRINT string, use '%%' instead. + b Bold + big Makes font relatively larger, equivalent to <span size="larger"> + i Italic + s Strikethrough + sub Subscript + sup Superscript + small Makes font relatively smaller, equivalent to <span size="smaller"> + tt Monospace font + u Underline -=item B<GPRINT:>I<vname>B<:>I<CF>B<:>I<format> +More details on L<http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html>. -Same as B<PRINT> but the result is printed into the graph below the legend. +[B<-G>|B<--graph-render-mode> {B<normal>,B<mono>}] -=back +There are 2 render modes: + +B<normal>: Graphs are fully Antialiased (default) + +B<mono>: No Antialiasing + +[B<-E>|B<--slope-mode>] + +RRDtool graphs are composed of stair case curves by default. This is in line with +the way RRDtool calculates its data. Some people favor a more 'organic' look +for their graphs even though it is not all that true. + +[B<-a>|B<--imgformat> B<PNG>|B<SVG>|B<EPS>|B<PDF>] + +Image format for the generated graph. For the vector formats you can +choose among the standard Postscript fonts Courier-Bold, +Courier-BoldOblique, Courier-Oblique, Courier, Helvetica-Bold, +Helvetica-BoldOblique, Helvetica-Oblique, Helvetica, Symbol, +Times-Bold, Times-BoldItalic, Times-Italic, Times-Roman, and ZapfDingbats. + +[B<-i>|B<--interlaced>] + +(this gets ignored in 1.3 for now!) -B<Caveat:> When using the B<PRINT> and B<GRPRINT> functions to -calculate data summaries over time periods bounded by the current -time, it is important to note that the last sample will almost always -yield a value of UNKNOWN as it lies after the last update time. This -can result in slight data skewing, particularly with the B<AVERAGE> -function. In order to avoid this, make sure that your end time is at -least one heartbeat prior to the current time. +If images are interlaced they become visible on browsers more quickly. -=over +[B<-T>|B<--tabwidth> I<value>] +By default the tab-width is 40 pixels, use this option to change it. -=item B<COMMENT:>I<text> +[B<-b>|B<--base> I<value>] -Like B<GPRINT> but the I<text> is simply printed into the graph. +If you are graphing memory (and NOT network traffic) this switch +should be set to 1024 so that one Kb is 1024 byte. For traffic +measurement, 1 kb/s is 1000 b/s. + +[B<-W>|B<--watermark> I<string>] + +Adds the given string as a watermark, horizontally centered, at the bottom +of the graph. + +=head2 Data and variables + +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>] -=item B<HRULE:>I<value>B<#>I<rrggbb>[B<:>I<legend>] +B<CDEF:>I<vname>B<=>I<RPN expression> -Draw a horizontal rule into the graph and optionally add a legend +B<VDEF:>I<vname>B<=>I<RPN expression> -=item B<VRULE:>I<time>B<#>I<rrggbb>[B<:>I<legend>] +You need at least one B<DEF> statement to generate anything. The +other statements are useful but optional. +See L<rrdgraph_data> and L<rrdgraph_rpn> for the exact format. -Draw a vertical rule into the graph and optionally add a legend +NOTE: B<Graph and print elements> -=item B<LINE>{B<1>|B<2>|B<3>}B<:>I<vname>[B<#>I<rrggbb>[B<:>I<legend>]] +You need at least one graph element to generate an image and/or +at least one print statement to generate a report. +See L<rrdgraph_graph> for the exact format. -Plot for the requested data, using the color specified. Write a legend -into the graph. The 3 possible keywords B<LINE1>, B<LINE2>, and B<LINE3> -generate increasingly wide lines. If no color is defined, -the drawing is done 'blind' this is useful in connection with the -B<STACK> function when you want to ADD the values of two -data-sources without showing it in the graph. +=head2 graphv -=item B<AREA>:I<vname>[B<#>I<rrggbb>[B<:>I<legend>]] +Calling rrdtool with the graphv option will return information in the +rrdtool info format. On the command line this means that all output will be +in key=value format. When used from the Perl and Ruby bindings a hash +pointer will be returned from the call. -Does the same as B<LINE?>, but the area between 0 and -the graph will be filled with the color specified. +When the filename '-' is given, the contents of the graph itself will also +be returned through this interface (hash key 'image'). On the command line +the output will look like this: -=item B<STACK>:I<vname>[B<#>I<rrggbb>[B<:>I<legend>]] + print[0] = "0.020833" + print[1] = "0.0440833" + graph_left = 51 + graph_top = 22 + graph_width = 400 + graph_height = 100 + graph_start = 1232908800 + graph_end = 1232914200 + image_width = 481 + image_height = 154 + value_min = 0.0000000000e+00 + value_max = 4.0000000000e-02 + image = BLOB_SIZE:8196 + [... 8196 bytes of image data ...] -Does the same as B<LINE?>, but the graph gets stacked on top of the previous -B<LINE?>, B<AREA> or B<STACK> graph. Depending on the type of the -previous graph, the B<STACK> will be either a B<LINE?> or an B<AREA>. -This obviously implies that the first B<STACK> must be preceded by an -B<AREA> or B<LINE?> -- you need something to stack something onto in -the first place ;) +There is more information returned than in the standard interface. +Especially the 'graph_*' keys are new. They help applications that want to +know what is where on the graph. -Note, that when you STACK onto *UNKNOWN* data, rrdtool will not draw -any graphics ... *UNKNOWN* is not zero ... if you want it to zero -then you might want to use a CDEF argument with IF and UN functions to -turn *UNKNOWN* into zero ... +=head1 ENVIRONMENT VARIABLES + +The following environment variables may be used to change the behavior of +C<rrdtoolE<nbsp>graph>: + +=over 4 + +=item B<RRDCACHED_ADDRESS> + +If this environment variable is set it will have the same effect as specifying +the C<--daemon> option on the command line. If both are present, the command +line argument takes precedence. =back -=head1 NOTES on legend arguments - -=head2 Escaping the colon - -In a ':' in a I<legend> argument will mark the end of the legend. To -enter a ':' into a legend, the colon must be escaped with a backslash '\:'. -Beware, that many environments look for backslashes themselves, so it may -be necessary to write two backslashes so that one is passed onto rrd_graph. - -=head2 String Formatting - -The text printed below the actual graph can be formated by appending special -escaped characters at the end of a text. When ever such a character occurs, -all pending text is pushed onto the graph according to the character -specified. - -Valid markers are: B<\j> for justified, B<\l> for left aligned, B<\r> for -right aligned and B<\c> for centered. In the next section there is an -example showing how to use centered formating. - -Normally there are two space characters inserted between every two items -printed into the graph. The space following a string can be suppressed by -putting a B<\g> at the end of the string. The B<\g> also squshes any space -inside the string if it is at the very end of the string. This can be used -in connection with B<%s> to supress empty unit strings. - - GPRINT:a:MAX:%lf%s\g - -A special case is COMMENT:B<\s> this inserts some additional vertical space -before placing the next row of legends. - -=head1 NOTE on Return Values - -Whenever rrd_graph gets called, it prints a line telling the size of -the gif it has just created to STDOUT. This line looks like this: XSIZExYSIZE. - -=head1 EXAMPLE 1 - - rrdtool graph demo.gif --title="Demo Graph" \ - DEF:cel=demo.rrd:exhaust:AVERAGE \ - "CDEF:far=cel,1.8,*,32,+"" \ - LINE2:cel#00a000:"D. Celsius" \ - LINE2:far#ff0000:"D. Fahrenheit\c" - -=head1 EXAMPLE 2 - -This example demonstrates the syntax for using IF and UN to set -I<*UNKNOWN*> values to 0. This technique is useful if you are -aggregating interface data where the start dates of the data sets -doesn't match. - - rrdtool graph demo.gif --title="Demo Graph" \ - DEF:idat1=interface1.rrd:ds0:AVERAGE \ - DEF:idat2=interface2.rrd:ds0:AVERAGE \ - DEF:odat1=interface1.rrd:ds1:AVERAGE \ - DEF:odat2=interface2.rrd:ds1:AVERAGE \ - CDEF:agginput=idat1,UN,0,idat1,IF,idat2,UN,0,idat2,IF,+,8,* \ - CDEF:aggoutput=odat1,UN,0,odat1,IF,odat2,UN,0,odat2,IF,+,8,* \ - AREA:agginput#00cc00:Input Aggregate \ - LINE1:agginput#0000FF:Output Aggregate - -Assuming that idat1 has a data value of I<*UNKNOWN*>, the CDEF expression - - idat1,UN,0,idat1,IF - -leaves us with a stack with contents of 1,0,NaN and the IF function -will pop off the 3 values and replace them with 0. If idat1 had a -real value like 7942099, then the stack would have 0,0,7942099 and the -real value would be the replacement. - -=head1 EXAMPLE 3 - -This example shows two ways to use the INF function. First it makes -the background change color during half of the hours. Then, it uses -AREA and STACK to draw a picture. If one of the inputs was UNKNOWN, -all inputs are overlaid with another AREA. - - rrdtool graph example.png --title="INF demo" \ - DEF:val1=some.rrd:ds0:AVERAGE \ - DEF:val2=some.rrd:ds1:AVERAGE \ - DEF:val3=some.rrd:ds2:AVERAGE \ - DEF:val4=other.rrd:ds0:AVERAGE \ - CDEF:background=val4,POP,TIME,7200,%,3600,LE,INF,UNKN,IF \ - CDEF:wipeout=val1,val2,val3,val4,+,+,+,UN,INF,UNKN,IF \ - AREA:background#F0F0F0 \ - AREA:val1#0000FF:Value1 \ - STACK:val2#00C000:Value2 \ - STACK:val3#FFFF00:Value3 \ - STACK:val4#FFC000:Value4 \ - AREA:wipeout#FF0000:Unknown - -The first CDEF uses val4 as a dummy value. It's value is removed immediately -from the stack. Then a decision is made based on the time that a sample was -taken. If it is an even hour (UTC time !) then the area will be filled. If -it is not, the value is set to UNKN and is not plotted. - -The second CDEF looks if any of val1,val2,val3,val4 is unknown. It does so by -checking the outcome of sum(val1,val2,val3,val4). Again, INF is returned when -the condition is true, UNKN is used to not plot the data. - -The different items are plotted in a particular order. First do the background, then use a -normal area to overlay it with data. Stack the other data until they are all plotted. Last but -not least, overlay everything with eye-hurting red -to signal any unknown data. - -Note that this example assumes that your data is in the positive half of the y-axis -otherwhise you would would have to add NEGINF in order to extend the coverage -of the rea to whole graph. +=head1 SEE ALSO + +L<rrdgraph> gives an overview of how B<rrdtool graph> works. +L<rrdgraph_data> describes B<DEF>,B<CDEF> and B<VDEF> in detail. +L<rrdgraph_rpn> describes the B<RPN> language used in the B<?DEF> statements. +L<rrdgraph_graph> page describes all of the graph and print functions. + +Make sure to read L<rrdgraph_examples> for tipsE<amp>tricks. =head1 AUTHOR -Tobias Oetiker E<lt>oetiker@ee.ethz.chE<gt> +Program by Tobias Oetiker E<lt>tobi@oetiker.chE<gt> -=head1 REFERENCES +This manual page by Alex van den Bogaerdt E<lt>alex@vandenbogaerdt.nlE<gt> +with corrections and/or additions by several people -[1] http://www.dotpoint.com/xnumber/rpn_or_adl.htm