# Template Helper Functions

Helper functions are meant to simplify the creation of templates and trap errors

## rrd::def

string rrd::def ( $vname, $rrdfile, $ds, [ $cf='AVERAGE' ] )

    $def = rrd::def('var1', $RRDFILE[0], $DS[0], 'MAX');

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html

## rrd::cdef

string rrd::cdef ( $vname, $rpn, )

    $def = rrd::cdef('var1_bits', 'var1,8,*' );

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html

## rrd::vdef

string rrd::vdef ( $vname, $rpn, )

    $def = rrd::vdef('var1_avg', 'var1,AVERAGE' );

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html

## rrd::line[1-3]

string rrd::line[1-3] ( $vname, $color, [ $text ], [ $stack ] )

    $def .= rrd::line1('var1', #ff00ff );

Draws a simple line one pixel wide without label

    $def .= rrd::line3('var1', '#ff00ff', 'Load' );

Draws a line three pixels wide with label “Load”

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html

## rrd::area

string rrd::area ( $vname, $color, [ $text ], [ $stack ] )

    $def .= rrd::area('var1', '#ff00ff', 'Load' );

Draws an area with label “Load”

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html

## rrd::gprint

string rrd::gprint ( $vname, $cf, [ $text ] )

    $def .= rrd::gprint('var1', 'MAX', '%4.2lf %s Max' );

    $def .= rrd::gprint('var1', array('MIN', 'MAX', 'AVERAGE'), '%4.2lf %s' );

If $cf is an array the legend will be formatted automatically

http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html

## rrd::color

string rrd::color ( $num )

Returns a color from the HTML color table

## rrd::gradient

string rrd::gradient ( $vname, [$start_color], [$end_color], [$label], [$steps] )

Creates a color gradient from $start_color to $end_color

    $def .= rrd::gradient('var1', '#ff0000', '#ffff00' );

Example

## rrd::cut

string rrd::cut ( $text, $length )

    $label = rrd::cut($LABEL[0], 18);

Cuts a text to a given length $length or fills it up to $length if needed.
This function is helpful if legend needs to be justified but length of label is unknown.

## rrd::ticker

string rrd::ticker ( $vname, $warning, $critical, [$fraction], [$opacity], [$color_OK], [$color_WARN], [$color_CRIT] )

Creates a colorized bar at the top of the chart which shows different colors depending on states OK, WARNING & CRITICAL

    $def .= rrd::ticker( "var1", $WARN[0], $CRIT[0] );

Example

## rrd::alerter

string rrd::alerter ( $vname, $label, $warning, $critical, [$opacity], [$unit], [$color_OK], [$color_WARN], [$color_CRIT], [$line_col] )

Creates colorized areas, which show different colors depending on states OK, WARNING & CRITICAL

    $def .= rrd::alerter( "var1", $LABEL[0], $WARN[0], $CRIT[0], "FF", $UNIT[0] );

Example