Creating Templates using Cacti
From ThemesWiki
| Official Page |
| Project Documentation |
| Download |
|
Cacti stores all collected information via RRDTool into files called rra. The RRDTool requires some parameters in order to create these rra files. Whenever we want to add a new device or create a new graph, we have to input these parameters. Inputting these parameters manually is flexible, but not very user friendly, and there is always a chance of error. Using templates, we can easily overcome this problem.
For example, let's say we have a network of four Linux servers, two Unix servers, and one Cisco router. Here, if we use a template, we will need to make only three different templates: one for the Linux servers, one for the Unix servers, and one for the Cisco router. You may ask why we have to make a template for the Cisco router? We will make it so that we can use it later.
Cacti templates can be imported and exported via the Console under Import/Export. You can only import templates that have been created on a system that is at the same, or an earlier, version of Cacti.
|
At the end of this tutorial, there is a list of third-party templates that can be imported. |
In this tutorial, we will learn how to:
- Use/add templates
- Make our own custom templates
- Import templates
- Export templates
Contents |
[edit] Types of Cacti templates
Cacti templates are broken into two areas:
1. Graph templates
2. Host templates
In the above figure, under the Templates section, you will see the three types of templates that come with the Cacti basic installation. If you click on one of those links, you will get the complete list of templates for that type.
[edit] Graph templates
Graphs are used to visualize the data you have collected. A graph template provides a skeleton for an actual graph. When you have more then one system/device, a graph template will save you lots of time and also reduce the possibility of error. Any parameters defined within a graph template are copied to all the graphs that are created using this template.
[edit] Creating a graph template
Now, we are going to create a new graph template. Under the Templates heading, click on Graph Templates. A list of the already available graph templates will be shown. Click on the Add link in the top right corner. You will get a screen like this:
Here, you have to give the values that will be used in future to create the graph.
| Field name
| Description
|
|---|---|
| Name
| Here, you have to input the template name. It can be anything, but it's always a good idea to have a relevant name.
|
| Title (--title) |
This title will be displayed on the top of the graph. So, we need to be careful here. The most used and popular title format is |host_description| - your graph name. Here, |host_description| is Cacti's own keyword. At the time of creating the graph, Cacti will replace this keyword with the hostname. |
| Field name
| Description
|
| Image Format
| The type of image that will be generated; the default, PNG, is fine for almost everyone. There are other two options, SVG and GIF.
|
| Height
| Height of the graph. The default value is 120 pixels, which is good enough for all graphs.
|
| Width
| Width of the graph. The default value is 500 pixels.
|
| Slope Mode (--slope-mode)
| RRDtool graphs are composed of staircase curves by default. This is in line with the way RRDtool calculates its data. Some people favor a more "organic" look for their graphs. RRDTool version 1.2 and above support smoothing of graphs, known as slope mode.
|
| Auto Scale
| Check this if you want the graph auto-scaled.
|
| Auto Scale Options |
If you checked Auto Scale, then you have to select one option from these four. Otherwise, ignore it. --alt-autoscale (ignoring given limits) : Here, RRDTool will ignore all the given limits. --alt-autoscale-max (accepting a lower limit) : It will accept the lower limit, but the max value will be generated automatically, depending on the stored data. --alt-autoscale-min (accepting an upper limit) : Same as the alt-autoscale-max except that it accepts the upper limit. (It requires RRDTool 1.2.x.) --alt-autoscale (accepting both limits): This accepts both upper and lower limits. |
| Logarithmic Scaling
| Choose this if you want logarithmic y-axis scaling.
|
| SI Units for Logarithmic Scaling
| This depends on Logarithmic Scaling, so if you haven't checked that you can ignore it.
|
| Rigid Boundaries Mode
| From the RRDTool manual, "Normally rrdgraph will automatically expand the lower and upper limit if the graph contains a value outside the valid range. With this option you can disable this behavior." If you don't really need it, you'd better leave it.
|
| Auto Padding
| Check this if you want to enable auto-padding in this template.
|
| Allow Graph Export
| You have to check this if you want to allow export from this graph template.
|
| Upper Limit
| The maximum value that will be displayed on the y-axis. This value is ignored when auto-scaling is turned on.
|
| Lower Limit
| The minimum value that will be displayed on the y-axis. This value is ignored when auto-scaling is turned on.
|
| Base Value
| Whether you want to base the y-axis labels on 1000 or 1024. This field will typically be set to 1024 for memory and 1000 for traffic measurements.
|
| Unit Grid Value
| Sets the unit value for the y-axis.
|
| Unit Exponent Value
| Sets the 10^e scaling of the y-axis. Valid values for this field are between -18 and 18. For example, you could use 3 to display everything in k (kilo) or -6 to display everything in u (micro).
|
| Vertical Label
| The text to print on the left edge of the graph. Usually, it is the units the data on the graph is measured in.
|
If you have checked Use Per-Graph Value (Ignore this Value), then every time while using this graph template to create a graph, you have to give an input for this option. It's always best to enable this option for title field.
After filling all these fields, click on the Create button. The graph template will be created.
Now, we need to add a Graph Template Item and Graph Item Inputs to complete this graph template.
[edit] Graph Template Item
Graph template items are the various items that will be shown on the graph.
To add a graph template item, click on Add on the right side of the Graph Template Items box.
You will get this page. The following are the fields that can be filled in:
| Field name
| Description
|
|---|---|
| Data Source
|
The data source to use for this graph item. Select the data source that you want to show on this graph item from the drop-down menu. All graph items may not have a data source. If you don't need any data source for this item, select None.
|
| Color
| Select the color that you want to use for this data source. It will only be enabled for graph item type LINE1 LINE3, AREA, and STACK.
|
| Opacity/Alpha Channel
| The opacity/alpha channel of the color. Not available for RRDTool-1.0.x.
|
| Graph Item Type
|
One of the most important fields. Here, you have to select how the data of this item will be shown on the graph. Possible types are: COMMENT, HRULE, VRULE, LINE1-3, Area, Stack, GPRINT, and LEGEND. |
| Consolidation Function
| Here, you have to tell the RRDTool which consolidation function to use. In most of the cases, AVERAGE is used. You may also use MAX, MIN, or LAST for GPRINT items.
|
| CDEF Function
| If you want to apply a CDEF function to the graph item, select one here. Check out the CDEF section of the manual for more information.
|
| Value
| This field is only used with the HRULE/VRULE graph item types. Type any valid integer to draw the line at for HRULE or the time of day HH:MM for VRULE.
|
| GPRINT Type
| If this item is a GPRINT, you can choose how you want the number to be formatted. You can add your own in the GPRINT Presets section of Cacti.
|
| Text Format
| You can enter text to be displayed on the legend here. This field is applicable for all graph item types except for the virtual LEGEND type.
|
| Insert Hard Return
| Check this box to force graph items onto the next line.
|
[edit] Graph Item Inputs
The second box is Graph Item Inputs. Graph item inputs are the input source through which the data will be collected. To add a new graph item input, click on the Add link on the right side of the Graph Item Inputs box.
Below are the various fields that have to be filled out for a graph input item:
| Fields
| Description
|
|---|---|
| Name
| This will be used as the identifier for this graph item input on both the graph template and the graph edit page.
|
| Description
| It will be displayed on the graph edit page. This field is optional.
|
| Field Type
| Here, you have to choose the field that you are going to associate with one or more graph items.
|
| Associated Graph Items
| Select the graph items that you want to accept the user input for.
|
After completing all these fields, click on the Create button. Do this again to add more graph item inputs to this graph template.
[edit] Host templates
Host templates are a little bit different from data templates and graph templates. A host template is the collection of associated graph templates and data queries that you want associated with a specific host type. As an example, for your localhost, you can use the Local Linux Machine. Click on Host Template in Templates section. You will get the list of host templates that comes with Cacti in the default installation. Let's open the Local Linux Machine.
As we can see, it has four associated graphs and one data query. When adding a new device, if we select Local Linux Machine as the host template, then all these associated graph and data query templates will be added to this device. Host templates are very useful for large networks with lots of devices of the same type.
[edit] Creating host templates
Creating a new host template is very simple. First, click on New in the top right corner.
You will get a page with a single input. Now, input your desired name for this host template. Here, I am using Debian Linux. Then, click on create.
The host template will be created with your desired name. It will look like this:
Our new template has been created successfully. Now, we need to add the associated graph templates and data queries.
To add a graph template, select your desired graph template from the drop-down menu and click Add. Do it again and again to add other graph templates. In this list, you will also see those graph templates that you made yourself.
To add a data query, select it from drop-down menu and click Add. Only add the queries you would normally want for that device type.
After adding all the associated graph templates and data queries, click on Save. The host template will be updated and you will see it on the Host Template list. It's ready for use on any device.
You can also edit the listed host template to add or remove a graph template and data query.
[edit] Using host templates
When adding a new device, you have to select the host template from the device section. From the drop-down host template, select your host template.
[edit] Importing templates
At the beginning of this tutorial, I told you that Cacti allows for importing and exporting of templates. This allows for the sharing of various templates between the users of Cacti or between your own installations.
This is the Template Imports page. In Cacti, you can import templates in two ways:
1. From a local file.
2. As pasted text.
Before importing templates into your Cacti installation, you must have a template that you want to import. At the end of this tutorial, I will give you a small list of templates that may be helpful for your network.
To import a template from a local file, click on Browse and select the file. If you are going to import from text, then paste the text in the input box. Now, if you want to use RRA settings from your installed system instead of the imported template, select Use defaults for this installation. Otherwise, select the other option, then the RRA setting will take from the imported template. (It is recommended that you use the first option, unless you are aware of the impacts of the second.)
Now, click on the save button. If everything goes fine, you will get a page like this:
Cacti will indicate if the template is imported successfully or not.
If it's a single OID-based template, you are done. Otherwise, you have to do a couple more steps.
For script-based templates, you have to copy the script that the template author distributed to the /path/to/cacti/scripts folder.
For SNMP data queries with an additional XML file holding the data query definition, you have to copy the XML file to the /path/to/cacti/resources/snmp_queries folder.
For Script data queries with an additional XML file holding the data query definition, you have to copy the XML file to the /path/to/cacti/resources/script_queries folder.
When importing the template, Cacti checks the version of Cacti that exported the template. Your Cacti version has to be equal or higher to import the template successfully; if your Cacti version is 0.8.7a, you cannot import a template that was created with 0.8.7b. You either have to upgrade your version, or find a template that was exported from 0.8.7a.
[edit] Exporting templates
Template exporting is very simple in Cacti. You can export any template within Cacti.
This is the default look of the Template Export page. At the top of the page, you can select what kind of template you are going to export. Possible values are:
1. Graph template
2. Data template
3. Host template
4. Data query
From the drop-down menu, select the template that you want to export. Now, select Include Dependencies if you want to also export all the dependent templates, graphs, and so on.
You can export the template in three modes:
1. Output to the Browser (within Cacti): Cacti will display the export XML within a Cacti window.
2. Output to the Browser (raw XML): Here, the template will be displayed on browser but as raw XML.
3. Save File Locally: Here, the exported template will be saved as a file. This is the recommended option if you want to share the template with others.
Now, click create. If you chose Output to the Browser, just copy the XML from the browser window. For Save File Locally, the browser will ask you where you want to save this file.
[edit] Important templates
Cacti users are a very friendly bunch. They have already created hundreds of templates for various different devices and graphs. A couple of useful templates that you can download are:
1. Apache stats Template: http://forums.cacti.net/about9861.html useful for web server.
2. MySQL Stats Template: http://forums.cacti.net/about11010.html.
3. Graph templates for Squid: http://forums.cacti.net/about4142.html.
4. Windows uptime statistics: http://forums.cacti.net/about10514.html.
You will get lots of templates at the following URL: http://forums.cacti.net/viewtopic.php?t=15067.
[edit] Additional References
logo design For instructions on Installing Cacti, click here
[edit] Source
The source of this content is Chapter 4: Creating Templates using Cacti of Cacti 0.8 Network Monitoring by Dinangkur Kundu, S. M. Ibrahim Lavlu (Packt Publishing, 2009).logo design by Kevin Josh 2010
Executive Editor Sean Lopez own : SEO Company and provider of Link Building Services and SEO Services
And Like Costumes and Halloween Costumes and criar sites
And Like The Global Information Network and Global Information Network
