Cacti 0.8 Network Monitoring — Save 50%
Monitor your network with ease!
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.
In this article by Dinangkur Kundu and S. M. Ibrahim Lavlu, we will learn how to:
- Use/add templates
- Make our own custom templates
- Import templates
- Export templates
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 article, there is a list of third-party templates that can be imported.
Types of Cacti templates
Cacti templates are broken into two areas:
- Graph templates
- 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.
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.
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.
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.
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:
When creating a graph item, you must always start with an AREA item before using STACK; otherwise, your graph will not render.
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:
After completing all these fields, click on the Create button. Do this again to add more graph item inputs to this graph template.
|Monitor your network with ease!|
eBook Price: £13.99
Book Price: £21.99
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.
These templates will only be associated, letting you quickly create these types of graphs from the host; it will not automatically create the graphs when you add a new host!
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.
Changes to the Host Template are not propagated to already existing devices. These changes are only applied to new devices. To adjust a current device, set its host template to None, save it, and then change its host template back to the original template and save it again. Attention! No items are deleted by this procedure.
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.
At the beginning of this article, 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:
- From a local file
- 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 article, 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.
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:
- Graph template
- Data template
- Host template
- 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:
- Output to the Browser (within Cacti): Cacti will display the export XML within a Cacti window.
- Output to the Browser (raw XML): Here, the template will be displayed on browser but as raw XML.
- 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.
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:
- Apache stats Template: http://forums.cacti.net/about9861.html—useful for web server.
- MySQL Stats Template: http://forums.cacti.net/about11010.html.
- Graph templates for Squid: http://forums.cacti.net/about4142.html.
- 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.
In this article, we learned about templates. Now, you can create or edit a graph template and host template. It's always a good practice to test every template locally before adding it to a production server. Also, we learned to how to import and export Cacti templates.
If you have read this article you may be interested to view :
|Monitor your network with ease!|
eBook Price: £13.99
Book Price: £21.99
About the Author :
Dinangkur Kundu is currently working as IT Support Analyst at Moriah College in Sydney, Australia, also running a local business directory for Bangladeshi people and developing web sites using concrete5 CMS in his free time.
Dinangkur started his career as a Visual Basic programmer for DEN – a hospital management system development company. Later, he moved to web programming and spent the majority of his career in the web arena, using open source technologies, which are the driving point of his technological advances. He worked as a LAMP developer for Quantumcloud – building and implementing an e-commerce solution, content management system, helpdesk and service-oriented application; as Chief Technical Officer he implemented and managed the Linux based internet gateway, mail, backup, revision control and over all security. On the rare occasion he's away from his computer, you can find him reading books in String theory and gaze on math books.
He dedicates this book to his parents – Dipty Rani Kundu and Ranjit Kumar Kundu, most extraordinary and beloved ones in his life; because of their love and blessing he is here and continuing his journey. He also thanks his sweet wife Suravi Sarkar for her faithful support in writing this book. He specially thanks his younger brother Shanku, who took care of his Mum and Dad in his absence, and pushed him to reach his goal.
He also wants to thank Rashmi Phadnis at Packt Publishing for being so patient with him.
S. M. Ibrahim Lavlu is a Linux wizard who has dedicated most of the time his for Linux and open source. All time he is busy with his technical world. He is also expert in PHP. Now working as a software engineer and deployment engineer at somewhere in... net ltd. He maintains the world’s largest Bangla blog community (www.somewhereinblog.net) and also the busiest site of Bangladesh. In his free time; Lavlu shares his knowledge on www.lavluda.com among his many tutorials and technical documents.
For successfully completing this book; all credit goes to my wife Tania Sabnam (www.tsabnam.com). And special thanks to cacti developer team for their great support.
Books From Packt