AREA and LINE show data. STACK them if you like.
LINE is the most basic command to draw something. A number should be appended, e.g. LINE1, LINE2. Normally you would use LINE1, but sometimes you want the line to be more visible.
LINE takes parameters. Of course you need to tell where the data should come from. To actually see the line, it needs a color. You also may want a legend to appear, if you do then this should also be specified here.
The following example uses a database with data from two data sources. One of them is alternating 200 and unknown, the other varies between 100 and 300.
This data is the basis of this tutorial. Look at the Y-axis, it scales automatically to fit the data. Look at how line x2 overlaps line x1 in some places.
The commands to create this graph are:
rrdtool graph graph-example1.png --start 900000000 --end=start+6300 DEF:x1=graph-example.rrd:x1:AVERAGE DEF:x2=graph-example.rrd:x2:AVERAGE LINE2:x1#FF0000:x1 LINE1:x2#0000FF:x2
This should all be on one line, separated by spaces. Please don't confuse the numbers in LINE2 and LINE1 with anything other than line width. They do not define the order in which the commands are drawn and they have nothing to do with the numbers in x1 and x2 either.
Special characters may have some meaning for operating systems, shells, command line interpreters or whatever it is you are using to recreate these examples. In my case "#" has a special meaning to my shell. My shell thinks it is separating the command from a comment.
I don't want my shell to interpret it, I want RRDtool to see that line as I intended it. Therefore I have to put quotation marks around the lines containing LINE: "LINE2:x1#FF0000:x1". This is not about RRDtool, this is about the shell. There's more than one way to escape those special characters, and there are more special characters. Use the method which you prefer best, when necessary. I won't repeat this reminder.
AREA is not difficult either. It is much like LINE, but this time the area under the line is filled in as well. I use the same example, but now I use AREA:x2 where previously I used LINE2:x2
Immediately you spot the problem: the AREA masks the LINE. This could be avoided by swapping the two statements (thus: AREA first, then LINE2):
That trick does it. But it won't work with two AREAs, one will overlap the other, no matter in which order I put them. Recent RRDtool versions now about transparency, which can be useful here:
The commands to create this graph are:
rrdtool graph graph-example1.png --start 900000000 --end=start+6300 DEF:x1=graph-example.rrd:x1:AVERAGE DEF:x2=graph-example.rrd:x2:AVERAGE AREA:x1#FF0000:x1 AREA:x2#0000FF80:x2
It's of no use to make the first AREA transparent:
Suppose the data comes from two devices, and you're not just interested in the separate numbers but also in the total. You can use a CDEF to add the numbers and show that total. But you can also display both values stacked:
This works with lines as well:
and, using version 1.2 RRDtool, with a combination of LINE and AREA:
I won't repeat all of the command, just the LINE and/or AREA parts:
AREA:x1#FF0000:x1 STACK:x2#0000FF:x2 LINE2:x1#FF0000:x1 STACK:x2#0000FF:x2+x1 LINE2:x1#FF0000:x1 AREA:x2#0000FF:x2:STACK
Use your imagination to create more exotic setups. For instance: get network statistics broken down in the various TCP ports, and display each protocol stacked; this shows not only total usage of your link, but you also see instantly which protocol uses the most of the bandwidth.
Do you like this information? Tell others! Don't you? Tell me!
This page was created by Alex van den Bogaerdt, an independent IT consultant. If you want to provide feedback or if you want to hire me please see