Cacti is a great monitoring and Graphing tool that runs on many Unix and Linux Operating systems. We recently wrote a guide on How to Install and configure Cacti Server on Ubuntu 18.04. This guide on How to Import templates on Cacti is based on that article.
What is Cacti Templates
You can unleash the real strength of Cacti is by using templates. There are three different types of templates with the basic Cacti installation:
- Data Templates – A data template provides a skeleton for an actual data source
- Graph Templates – A graph template provides a skeleton for an actual graph
- Host Templates – Instead of abstracting the fields of a host, a host template allows you to associate graph templates and data queries with a given host type.
How to Import templates on Cacti
Templates on Cacti are imported using import_package.php script available on /usr/share/cacti/cli/ directory.
# /usr/share/cacti/cli/import_package.php --help Cacti Import Template Utility, Version 1.1.38, Copyright (C) 2004-2018 The Cacti Group usage: import_package.php --filename=[filename] [--remove-orphans] [--with-profile] [--profile-id=N A utility to allow signed Cacti Packages to be imported from the command line. Required: --filename The name of the gziped package file to import Optional: --preview Preview the Template Import, do not import --with-profile Use the default system Data Source Profile --profile-id=N Use the specific profile id when importing --remove-orphans If importing a new version of the template, old elements will be removed, if they do not exist in the new version of the template.
The syntax is:
# /usr/share/cacti/cli/import_package.php --filename=[filename]
Downloading Cacti Templates
Cacti Templates for Host, Graph, and Data are available on https://docs.cacti.net/templates. You can download a template you want from the link to the local system where Cacti server runs. Let’s consider an example to install SNMP Generic device template
Once the package is downloaded, install it like below:
After the installation, Data Query XML files are copied into Cacti snmp_queries directory:
# ls -1 /usr/share/cacti/resource/snmp_queries/ host_disk.xml index.php interface.xml net-snmp_devio.xml net-snmp_disk.xml
Let’s also add Local Linux system
Then import it using the command:
This last package comes with the following templates – linux, UNIX, net-snmp, load, cpu, memory, context switches, interrupts, interface, errors, disk, logins, processes, iops
# wget https://docs.cacti.net/_media/template:package:netsnmp_device.xml.gz -O netsnmp_device.xml.gz # /usr/share/cacti/cli/import_package.php --filename=./netsnmp_device.xml.gz
Confirm that the templates have been imported on Cacti Admin interface. Login using admin user account, then go to:
Console > Templates