Wednesday, October 9, 2024
Google search engine
HomeGuest BlogsHow to Import templates on Cacti

How to Import templates on Cacti

Cacti is a great monitoring and Graphing tool that runs on many Unix and Linux Operating systems. We recently wrote guides on Cacti installation, check them out using the following links:

This guide on How to Import templates on Cacti is based on that article.

What are 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. You can locate this script by using the command below:

$ sudo find / -name import_package.php
/var/www/html/cacti/cli/import_package.php

From the output we can confirm its location is /var/www/html/cacti/cli/import_package.php. This may vary depending on how your installation was done.

Check script usage guide:

$ sudo /var/www/html/cacti/cli/import_package.php --help
Cacti Import Template Utility, Version 1.2.19 (DB: 1.2.19), Copyright (C) 2004-2022 The Cacti Group

usage: import_package.php --filename=[filename] [--only-info] [--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:
    --only-info       Output the info section of the package, do not import
    --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 usage syntax is:

sudo /var/www/html/cacti/cli/import_package.php --filename=[filename]

Where:

  • [filename] is the name of the gziped package file to import

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

wget https://docs.cacti.net/_media/template:package:generic_snmp_device.xml.gz

Once the package is downloaded, install it like below:

sudo /var/www/html/cacti/cli/import_package.php --filename=./generic_snmp_device.xml.gz

Sample output:

Cacti has imported the following items for the Package:
Package Files
/var/www/html/cacti/site/resource/snmp_queries/interface.xml [written]
CDEF
[success] Turn Bytes into Bits [unchanged]
GPRINT Preset
[success] Normal [unchanged]
Data Input Method
[success] Unix - Ping Host [updated]
Table: data_input, Column: input_string, New Value: 'perl <path_cacti>/scripts/ping.pl <hostname>', Old Value: 'perl <path_cacti>/scripts/ping.pl <ip>'
Table: data_input_fields, Column: data_name, New Value: 'hostname', Old Value: 'ip'
[success] Get SNMP Data [unchanged]
[success] Get SNMP Data (Indexed) [updated]
Table: data_input_fields, Column: allow_nulls, New Value: 'on', Old Value: ''
Data Template
[success] Unix - Ping Host [new]
[success] SNMP - Generic OID Template [new]
[success] Interface - Traffic [new]
[success] Interface - Errors/Discards [new]
[success] Interface - Unicast Packets [new]
[success] Interface - Non-Unicast Packets [new]
Graph Template
[success] Unix - Ping Latency [new]
[success] SNMP - Generic OID Template [new]
[success] Interface - Traffic (bits/sec) [new]
[success] Interface - Errors/Discards [new]
[success] Interface - Unicast Packets [new]
[success] Interface - Non-Unicast Packets [new]
[success] Interface - Traffic (bytes/sec) [new]
[success] Interface - Traffic (bits/sec, 95th Percentile) [new]
[success] Interface - Traffic (bits/sec, Total Bandwidth) [new]
[success] Interface - Traffic (bytes/sec, Total Bandwidth) [new]
[success] Interface - Multicast Packets (Legacy) [new]
[success] Interface - Broadcast Packets (Legacy) [new]
Data Query

After the installation, Data Query XML files are copied  into Cacti snmp_queries directory:

$ ls -1 /var/www/html/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

wget https://docs.cacti.net/_media/template:package:local_linux_machine.xml.gz -O local_linux_machine.xml.gz

Then import it using the command:

sudo /var/www/html/cacti/cli/import_package.php --filename=./local_linux_machine.xml.gz

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
sudo /var/www/html/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

cacti templates 01
cacti templates 02
cacti templates 03
cacti templates 04
RELATED ARTICLES

Most Popular

Recent Comments