Cacti (home)ForumsDocumentation

Differences

This shows you the differences between two versions of the page.

manual:100:7_examples [2010/02/21 12:59] (current)
Line 1: Line 1:
 +====== Examples ======
  
 +For these examples, we will use some dummy rrd file, if not denoted otherwise. Create it using 
 +<code>rrdtool create test.rrd DS:test:COUNTER:600:U:U RRA:AVERAGE:0.5:1:100</code>
 +
 +**Example:**
 +<code>/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</code>
 +
 +{{:manual:087:default.png|Default sine curve}}
 +===== 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:**
 +<code>/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</code>
 +
 +{{:manual:087:autoscale.png|Autoscaled sine curve}}
 +
 +
 +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:**
 +<code>/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</code>
 +
 +{{:manual:087:upper-limit.png|Upper Limit, when limit is not exceeded by data}}
 +
 +==== 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:**
 +<code>/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</code>
 +
 +{{:manual:087:upper-limit-exceed.png|Upper Limit, when limit **IS** exceeded by data}}
 +
 +==== 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:**
 +<code>/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</code>
 +
 +{{:manual:087:upper-limit-exceed-capped.png|Upper Limit, capped, when limit **IS** exceeded by data}}
 +
 +**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:**
 +<code>/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</code>
 +
 +{{:manual:087:small-stddev.png|Small Standarddeviation using defaults}}
 +
 +==== Using --alt-autoscale ====
 +
 +In this case, using --alt-autoscale helps:
 +**Example:**
 +<code>/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</code>
 +
 +{{:manual:087:small-stddev-autoscale.png|Small Standarddeviation using --alt-autoscale}}
 +
 +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:**
 +<code>/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</code>
 +
 +{{:manual:087:small-stddev-autoscale-alt-y-grid.png|Using --alt-y-grid to adjust y-axis}}





Personal Tools