To create a new data template, select Data Templates under the Templates heading and click Add.
The first thing you must do is give the template a name. This name has nothing to do with the data source name, but is what you will use to identify the template throughout Cacti. Second, you will notice a list of data source/data source item field names with Use Per-Data Source Value checkboxes next to each one. The nice thing about templates in Cacti is that you can choose whether to template each field on a per-field basis. If you leave the checkbox unchecked, every data source attached to the template will inherit its value from the template. If the checkbox is checked, every data source attached to the template will contain its own value for that particular field.
Table 11-4. Field Description: Data Templates
|This is the name that cacti uses to identify this Data Template|
|The Title of the Data Source will be derived from this. If Use Per-Data Source Value (Ignore this Value) is unchecked, the string entered here is take literally. Checking this box allows for target-specific values by substituting cacti's built-in variables (|host_description| will be substituted by the description of the host this Data Template will be associated with.)|
|Data Input Method||Here is where you tell cacti how it is supposed to fetch data for this data source. There are several data input sources that come with cacti, and you can add your own by going to Data Input Methods. If this RRD file is being populated outside of cacti, make sure to leave this field set to “None”.|
|Associated RRAs||You need to associate the data source with at least one RRA so RRDTool knows how often and for how long to keep its data. You will almost always want to select all of these values however so you can render daily, weekly, monthly, and yearly graphs.|
|Step|| This tells RRDTool how many seconds there will be between updates. The default is 300 seconds (5 minutes), and is sufficient for most installations.
Note: When using 1 min polling, Step has to be adjusted, e.g. to a value of 60.
This must match RRA definitions to work properly! You will have to change them!
|Data Source Active||This is a quick and easy to tell Cacti to stop gathering data for this data source. The data source can still be used on graphs, but no data will be fed to it until it is made active again.|
Note: For most data templates, you will want to check the Use Per-Graph Value checkbox for the name field so each data source using this template has its own unique name. It also makes sense to enter an inital value in this field that includes the variable |host_description| for organizational purposes.
When you are finished filling in values for the data template, click Create and you will be presented with a screen similar to the data source edit screen.
Figure 11-2. Adding a Data Template
Like a graph, a data source can have more than one item. This is useful in situations where a script returns more than piece of data at one time. This also applies to data queries, so you can have a single data template that contains both inbound and outbound traffic, rather than having to create a separate data template for each.
Table 11-5. Field Description: Data Source Items
|Internal Data Source Name||This is the name used by RRDTool to identify this particular data source within the RRD file. RRDTool places a limit of 19 alphanumeric characters (plus '_' and '-') on this field. Each Data Source (there may be more than one per rrd file) has its own name. It is used to access the data. Therefor, it is wise to choose some “self-explanatory” name. For SNMP data, it is a good idea to use the string representation of the OID (if it is not too long)|
|Minimum Value||Here is where you specify the minimum value that is expected for this data source in the RRD file. If a value lower than the minimum is given, it will be stored as Unknown (U). Using negative values requires this to be changed.|
|Maximum Value|| Here is where you specify the maximum value that is expected for this data source in the RRD file. If a value higher than the maximum is given, it will be stored as Unknown (U).
Note: When creating a new data source, this value defaults to 100. This is not always a good choice. Entering 0 will result in “no Maximum Value”
|Data Source Type|| There are four types of data that RRDTool can represent for any given data source: COUNTER, GAUGE, ABSOLUTE, and DERIVE.
|Heartbeat|| If rrd's are not updated within Heartbeat's seconds, the needed data point is assumed to be NaN (“Not a Number = no valid data).
As defined by RRDTool: “The maximum amount of time that can pass before data is entered as “unknown”. This field is usually '600' or 2 data gathering intervals”.
Note: When using 1 min polling, Heartbeat has to be adjusted, e.g. to a value of 120.
|OID||Numerical representation of the OID that will be used for querying the target to retrieve data|
CAVEAT! Adding a new data source item will affect new data sources (rrd files) only! Existing data sources (rrd files) that are related to the modified Data Template will NOT be modified. This restriction is due to the fact, that rrdtool does not provide a command to add a new data source item to an existing data source (rrd file). In such a case, you will have to re-create the whole data source (rrd file), e.g. by deleting this very file, loosing all historical data. Cacti will then re-create the rrd file based on the modified definition during the next polling cycle.
Assuming you selected a data input source on the previous screen, you should now be presented with a Custom Data box. Each custom data field is per-field templatable as all of the other data source fields are. Even if you select the Use Per-Data Source Value checkbox, it might be useful to specify a value that will be used as an “inital value” for any data source using this data template.
Applying a data template to a data source is a very simple process. The first thing you must do is select the data source you want to apply the template to under Data Sources. Under the Data Template Selection box, select the data template that you want to apply to the data source and click Save.
Once the template is applied to the data source, you will notice that you can only change values for the fields that you checked Use Per-Data Source Value for.
For this task, let's stick to SNMP stuff. For you to be able to reproduce this example, I've chosen the UDP information of the IP MIB.
snmpwalk -c <community string> -v1 <device> udp UDP-MIB::udpInDatagrams.0 = Counter32: 7675 UDP-MIB::udpNoPorts.0 = Counter32: 128 UDP-MIB::udpInErrors.0 = Counter32: 0 UDP-MIB::udpOutDatagrams.0 = Counter32: 8406 ... more to follow ...
As cacti does not use the MIBs but pure ASN.1 OIDs, let's search the OID used as udpInDatagrams:
snmpwalk -c <community string> -v1 -On <device> udp .188.8.131.52.184.108.40.206.0 = Counter32: 7778 .220.127.116.11.18.104.22.168.0 = Counter32: 129 .22.214.171.124.126.96.36.199.0 = Counter32: 0 .188.8.131.52.184.108.40.206.0 = Counter32: 8514 ... more to follow ...
The needed OID is .220.127.116.11.18.104.22.168.0. Now learn how to enter this into a new Cacti Data Template: Please proceed to Data Templates and filter for SNMP. Check the SNMP - Generic OID Template
After clicking Go, you're prompted with a new page to enter the name for the new Data Template:
Due to the filter defined above, you won't see the new Template at once, so please enter udp as a new filter to find:
Now select this entry to change some definitions according to the following images:
for the upper half of the page and
for the lower one. Please pay attention to change the MAXIMUM value to 0 to prevent data suppression for values exceeding 100. And you saw the OID .22.214.171.124.126.96.36.199.0 from above, didn't you? Please copy another one for OID .188.8.131.52.184.108.40.206.0, using the description udpOutDatagrams