Templates
Templates are a core mechanism in NetXMS for managing data collection and agent configuration at scale. A template is a special object which can have DCIs configured and grouped for similar or logical purposes, along with agent policies, and applied to relevant nodes or other data collection targets (such as clusters or collectors). Templates can be accessed from the Templates perspective in the management client.
How Templates Work
Often you have a situation when you need to collect same metrics from different nodes. Such configuration can easily fall into repeating one action many times. Things may become even worse when you need to change something in already configured DCIs on all nodes — for example, increase a threshold for CPU utilization. To avoid these problems, you can use data collection templates.
When you create a template and configure DCIs for it, nothing happens — no data collection will occur. Then, you can apply this template to one or multiple nodes, and as soon as you do this, all DCIs configured in the template object will appear in the target node objects, and the server will start data collection for these DCIs. If you then change something in the template data collection settings — add a new DCI, change a DCI’s configuration, or remove a DCI — all changes will be reflected immediately in all nodes associated with the template.
You can apply an unlimited number of templates to a node, so you can create individual templates for each group of metrics (for example, generic performance metrics, MySQL metrics, network counters, etc.) and combine them as needed.
Template Objects
Templates are organized in the object tree under the Templates root object. You can create a flat list of templates or organize them in template groups for better management.
What Templates Contain
A template can contain:
| Element | Description |
|---|---|
Data Collection Items (DCIs) |
Metrics to collect, their polling intervals, and storage settings |
Thresholds |
Conditions that trigger events when DCI values cross defined limits |
Agent Configuration Policies |
Configuration snippets pushed to agents (see Agent Policies) |
Log Parser Policies |
Log monitoring rules deployed to agents |
File Delivery Policies |
Files delivered to managed hosts (see File Delivery) |
User Support Application Policies |
Configuration for user support application |
To configure DCIs in the template, click on the template object in the Templates perspective, then right-click in the Data Collection tab view and select New parameter… or New table… for further data collection configuration. You can configure DCIs in the same way as on node objects.
Another way to add configuration to a template is to create a DCI in the Infrastructure or Network perspective and convert it to a template item.
Applying Templates to Nodes
To apply a template to one or more nodes, right-click on the template object in the Templates perspective and select Apply to… A popup will appear with objects in the Infrastructure and Network perspectives available for selection. Select the objects you wish to apply the template to and click OK (you can select multiple nodes by holding Ctrl).
Alternatively, in the Infrastructure or Network perspective, select one or more objects, right-click and select Apply template…
Templates can be assigned to an exclusion group (set on the template’s Automatic Apply Rules property page). Only one template from an exclusion group can be applied to an object at a time — applying a conflicting template manually asks whether to replace the existing one, and during automatic apply the already-applied template wins.
Removing Templates from Nodes
To remove a link between a template and a node, right-click on the template object in the Templates perspective and select Remove from… A popup will appear with objects that have the template already applied. Select the objects you wish to remove the template from and click OK.
Alternatively, in the Infrastructure or Network perspective, select one or more objects, right-click and select Remove template… A popup will appear with all applied templates. Select the templates to be removed and click OK.
When removing a template, you have two options:
-
Remove DCIs from node (default) — all DCIs associated with the template are removed from the node.
-
Unbind DCIs from template — all DCIs related to the template remain configured on the node, but the association between the DCIs and the template is removed. Any further changes to the template will not be reflected in these DCIs. If you later reapply the template to the node, you will have two copies of each DCI — one standalone (remaining from the unbind operation) and one related to the template (from the new apply operation).
Agent policies deployed by the template are always uninstalled from the node on removal, regardless of the chosen option.
If you delete the template object itself, the Delete Template dialog offers the same choice: Remove DCIs from all objects (default) deletes all DCIs created from the template, while Unbind DCIs from template (keep as standalone) keeps them on the objects as standalone DCIs.
Macros in Template Items
You can use macros in several fields of template DCIs.
When the template is applied to an object, macros are expanded in the DCI name, description, instance name, and instance discovery data.
When a template update propagates to objects the template is already applied to, macros are re-expanded in the name, description, system tag, and user tag — instance fields are not re-expanded.
Macros start with %{ and end with }.
| Macro | Expands to |
|---|---|
|
Node unique ID |
|
Node name |
|
Node primary IP address |
|
String returned by script name from the Script Library. Inside the script, you can access the current node’s properties via the |
|
Result of expanding text using the owner object’s standard macro expansion |
For example, if you enter the following in the description field of a template DCI:
My IP address is %{node_primary_ip}
When applied to a node with primary IP address 10.0.0.1, the DCI on the node will have the description:
My IP address is 10.0.0.1
| If you change something on the node (for example, its name), changes will not be reflected automatically in DCI texts generated from these macros. However, they will be updated if you reapply the template to the node or on a housekeeper run. |
Next Steps
-
DCI Templates — creating and managing data collection templates
-
Policy Templates — managing agent policies through templates
-
Auto-Apply Rules — automatically applying templates to nodes