[-t|--title title] [DEF:vname=rrd:ds-name:CF] [CDEF:vname=rpn-expression] [PRINT:vname:CF:format] [GPRINT:vname:CF:format] [COMMENT:text] [HRULE:value#rrggbb[:legend]] [VRULE:time#rrggbb[:legend]] [LINE{1|2|3}:vname[#rrggbb[:legend]]] [AREA:vname[#rrggbb[:legend]]] [STACK:vname[#rrggbb[:legend]]]
PNG output is recommended, since it takes up to 40% less disk space and 20-30% less time to generate than a GIF file.
If no graph functions are called, the graph will not be created.
The x-axis label is configured, using the following format:
GTM:GST:MTM:MST:LTM:LST:LPR:LFM
You have to configure three elements making up the x-axis labels and grid. The base grid (G??), the major grid (M??) and the labels (L??). The configuration is based on the idea that you first specify a well known amount of time (?TM) and then say how many times it has to pass between each grid line or label (?ST). For the label you have to define two additional items: The precision of the label in seconds (LPR) and the strftime format used to generate the text of the label (LFM).
The ?TM elements must be one of the following keywords: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH or YEAR.
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.
MINUTE:10:HOUR:1:HOUR:1:0:%X
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.
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)
--imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
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 vname+3/2 becomes 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.
The rpn-expression in the CDEF function takes both, constant values as well as vname variables. The following operators can be used on these values:
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.
printf
the result to stdout using format. In the format string there should be a '%lf' or '%le' marker in the place where the
number should be printed.
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!
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.
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 ... =back
Valid characters are: j for justified, l for left aligned, r for right aligned and c for centered. In the next section there is an example showing how to use centered formating.
A special case is COMMENT:\s this inserts some additional vertical space before placing the next row of legends.
rrdtool graph demo.gif --title="Demo Graph" \ DEF:cel=demo.rrd:exhaust:AVERAGE \ "CDEF:far=cel,32,-,0.55555,*" \ LINE2:cel#00a000:"D. Celsius" \ LINE2:far#ff0000:"D. Fahrenheit\c"
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.
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:whipeout#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 assumesthat 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 AUTHOR