Examples
For these examples, we will use some dummy rrd file, if not denoted otherwise. Create it using
rrdtool create test.rrd DS:test:COUNTER:600:U:U RRA:AVERAGE:0.5:1:100
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Default" \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN \ LINE1:sine#0000ff:sine
Managing Graph Y-Axis
By default, rrdtool will create autoscaling graphs. Cacti's defaults are
- check Auto Scale
- select –alt-autoscale (ignoring given limits)
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Autoscale" \ --alt-autoscale \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN \ LINE1:sine#0000ff:sin
This way, the graphs y-axis will automatically adjust for the range of values displayed. The common drawback is, that you will have to pay attention for the current y-axis scale, because it “jumps” from low to high values.
Using an Upper Limit
In order to define the same y-axis dimensions for a graph template,
- check Auto Scale
- select –alt-autoscale-min (accepting an upper limit, requires rrdtool 1.2.x)
- define a numeric value for upper limit. e.g. 2
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Upper Limit" \ --alt-autoscale-min \ --upper-limit=2 \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN \ LINE1:sine#0000ff:sine
Data exceeds given Limit
The following example uses the same graph configuration. But the data was tweaked to exceed the given limit. You will notice, that rrdtool automatically extends the y-axis despite the given –upper-limit!
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Upper Limit" \ --alt-autoscale-min \ --upper-limit=2 \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN,3,* \ LINE1:sine#0000ff:sine
Data exceeds given Limit, Capped
The following example uses the same graph configuration; data tweaked to exceed the given limit. Now we use
- check Auto Scale
- select –alt-autoscale-min (accepting an upper limit, requires rrdtool 1.2.x)
- define a numeric value for upper limit. e.g. 2
- check Rigid Boundaries Mode (–rigid)
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Upper Limit" \ --alt-autoscale-min \ --upper-limit=2 \ --rigid \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN,3,* \ LINE1:sine#0000ff:sine
Notice:
Please note, that the upper y-axis is capped only, as we use –upper-limit
Graphing Data with a Small Standard Deviation
Sometimes, the automatic scaling of y-axis fails.
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Small Standarddeviation" \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN,1000,+ \ LINE1:sine#0000ff:sine
Using --alt-autoscale
In this case, using –alt-autoscale helps: Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Small Standarddeviation using Autoscale" \ --alt-autoscale \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN,1000,+ \ LINE1:sine#0000ff:sine
That indeed looks better. But you can't judge from this graph, how big the amplitude of the sine is.
Using --alt-autoscale and --alt-y-grid
Using the alternate grid (–alt-y-grid) solves this problem.
Example:
/usr/bin/rrdtool graph - \ --imgformat=PNG \ --end=now \ --start=end-150000 \ --title="Small Stddev using Autoscale and --alt-y-grid" \ --alt-autoscale \ --alt-y-grid \ --slope-mode \ DEF:a="test.rrd":test:AVERAGE \ CDEF:sine=a,POP,NOW,TIME,-,10000,/,SIN,1000,+ \ LINE1:sine#0000ff:sine