Cacti (home)ForumsDocumentation
Table of Contents

Templates

Why Templates?

You've surely seen all those Template stuff and may have asked yourself, “Why Templates”. You may compare them to Macros or Subroutines of commonly known programming languages.

Imagine, you would have to define all rrdtool create parameters to define the logical layout of each and every rrd file. And you would have to define all rrdtool graph parameters to create those nice graphs, for every new graph. Well, this would yield maximum flexibility. But maximum effort, too.

But in most installations, there are lots of devices of the same kind. And there are lots of data of the same kind, e.g. traffic information is needed for almost every device. That's why all parameters needed to create a traffic rrd file are defined by a Data Template, in this case known as Interface - Traffic. These definitions are used by all Traffic-related rrd files.

The same approach is used for defining Graph Templates. This burden is done only once. And all parameters defined within such a Graph Template are copied to all Graphs that are created using this Template.

The last type of Templates are the Host Templates. They are not related to some rrdtool stuff. The purpose of Host Templates is to group all Graph Templates and Data Queries (these are explained later) for a given Device type. So you will make up a Host Template e.g. for a specific type of router, switch, host and the like. By assigning the correct Host Template to each new Device, you'll never forget to create all needed Graphs.

Well, nice stuff, isn't it? But here comes the bad news. Unlike a Subroutine, Templates are not invoked at runtime:

Graph Templates

In Cacti, a graph template provides a skeleton for an actual graph. If you have many graphs that share most of their characteristics, using a graph template would probably make sense. After a graph is attached to a particular graph template, all changes made to the graph template will propagate out to all of its graphs.

Almost every setting of a Graph Template is propagated to all related Graphs when saving the changes. But you may encounter problems when checking the Use Per-Graph Value (Ignore this Value) checkbox. When creating new Graphs, the latest definitions are taken into account.

Data Templates

In Cacti, a data template provides a skeleton for an actual data source. If you have many data sources that share most of their characteristics, using a data template would probably make sense.

No change of a Data Template is propagated to already existing rrd files. But most of them may be changed by using rrdtool tune from command line. Pay attention to not append new Data Source Items to already existing rrd files. There's no rrdtool command to achieve this!

Host Templates

Host templates in Cacti serve a different purpose then data and graph templates. Instead of abstracting the fields of a host (this will be part of cacti 0.8.8), a host template allows you to associate graph templates and data queries with a given host type. This way when you assign a host template to a host, all of the relevant graphs to that host type are only one click away from the user.

No change of a Host Template is propagated to already existing Devices. But when creating a new one, latest definitions are taken into account. But there's an easy (bit tedious, perhaps) way to apply changes to already existing Devices: First, change the Host Template to None, then change it back to the desired one. All new items are now associated with this Device. Attention! No items are deleted by this procedure.






Personal Tools