Device templates
A device template says which sensors a device gets when discovery finds it. Discovery reads a fingerprint of the device (does it answer ping, which TCP ports are open, what the SNMP agent says about itself, whether an SSH or WinRM login works), matches it against every template, and proposes the sensors of the templates that match. Nothing is created until the proposal is accepted.
Probeward ships its templates inside the binary. You can add your own, and templates imported from LibreNMS, in a template directory on the server.
The template directory
Set PROBEWARD_TEMPLATE_DIR (see configuration) to a directory the server can read, for example /etc/probeward/templates. The Compose reference installation sets it to /var/lib/probeward/templates, kept in the templates volume; see install for how to put your own files there. Every file ending in .yaml in it, and in its subdirectories one level down, is read at the start of each discovery job, so a new or changed file is used by the next discovery without a restart. The LibreNMS importer writes into the librenms subdirectory by default.
A file is left out, and the reason logged as device template left out, when:
- it is not valid YAML, or not a valid template (an unknown key, an unknown sensor kind, invalid sensor parameters, limits that do not nest, a bad regular expression);
- its id is already used by a shipped template or by another file in the directory. A file in the directory never replaces a shipped template; give your copy its own id;
- it is larger than 8 MiB. More than 4096 files in the directory is refused as a whole.
Templates in the directory are never written back by Probeward, except by the importer when you run it with --apply.
Format
id: device.my-pdu # stable, 1 to 128 characters
version: 1 # raise it when you change the template
name: Rack PDU
description: The PDUs in rack A, read over SNMP.
role: primary # primary or addon
priority: 120
match:
all: # every condition must hold
- sys_object_id_prefix: "1.3.6.1.4.1.32473.1"
any: [] # at least one must hold, when not empty
protocol_chain: [snmp, icmp]
sensors:
- kind: ping
name: Ping
when:
- icmp_reachable: true
- kind: snmp_custom_oid
name: Inlet current
params:
oid: 1.3.6.1.4.1.32473.1.2.0
scale: 0.1
unit: A
channel_limits:
value: { warn_max: 14, error_max: 16 }| Key | Meaning |
|---|---|
id | The template's identity. Shipped templates start with device.; imported ones with device.librenms.. |
version | At least 1. |
name, description | Shown with the proposal. |
role | primary: names the device and decides how it is polled. Of the matching primary templates the one with the highest priority wins; on a tie, the lower id. addon: adds its sensors on top, and every matching add-on applies. |
priority | A whole number. The shipped templates use 10 to 80: device.reachability-only 10, device.generic-snmp 50, device.linux-net-snmp 80. Imported templates use 60 to 2999 (see LibreNMS import). |
match | all and any, lists of conditions. A template must have at least one condition. |
protocol_chain | The protocols discovery prefers, in order: snmp, ssh, http, icmp, winrm. |
sensors | At least one sensor. |
source | Set by the importer on generated templates: origin, files, upstream_version, sha256, licence. Leave it out of your own. |
Conditions
| Condition | Holds when |
|---|---|
icmp_reachable: true | The device answered ping (false: it did not). |
snmp_reachable: true | The SNMP agent answered. |
sys_object_id_prefix: "1.3.6.1.4.1.9" | sysObjectID starts with these arcs. 1.3.6.1.4.1.9 matches 1.3.6.1.4.1.9.1.5 but not 1.3.6.1.4.1.91. |
sys_object_id_starts_with: ".1.3.6.1.4.1.9" | sysObjectID, written with a leading dot, starts with this text. Compares characters, so it also matches .1.3.6.1.4.1.91. |
sys_object_id_regex: '^\.1\.3\.6\.1\.4\.1\.9\.1\.' | sysObjectID, written with a leading dot, matches the regular expression. |
sys_descr_regex: "^Linux " | sysDescr matches the regular expression. |
sys_descr_contains: "RouterOS" | sysDescr contains the text, case-sensitive. |
snmp_supports: cpu | The agent offers uptime, cpu, memory, interfaces, storage or ups. |
snmp_get: {oid, op, value} | One SNMP object compares with the listed values; see below. |
tcp_port_open: 443 | The port accepted a connection. |
banner_regex: {port: 22, pattern: "OpenSSH"} | The banner read from the port matches. |
ssh_ok: true | An SSH credential logged in. |
uname_regex: "^Linux 6" | uname -sr over SSH matches. |
winrm_listening: true | A WinRM listener answered, before any login. |
winrm_ok: true | A Windows credential logged in over WinRM. |
proxmox_web: true | The web interface on port 8006 answered as Proxmox VE. |
proxmox_api: true | A secret credential offered to discovery is an API token that Proxmox accepted, and could read the nodes, guests and storages. |
vmware_web: true | Port 443 answered the vSphere API: an ESXi host or vCenter. |
vmware_api: true | A vsphere credential offered to discovery logged in and could read the hosts, datastores and machines. |
docker_web: true | Port 2376, the Docker daemon's TLS port, accepted a TLS connection. |
docker_api: true | A tls_client credential offered to discovery was accepted by the daemon, which listed its containers. |
windows_regex: "Server 2022" | The Windows caption and version match. |
windows_service: W3SVC | A server-role service (one of DNS, DHCPServer, NTDS, Netlogon, DFSR, W32Time, W3SVC, MSSQLSERVER, SQLSERVERAGENT, Spooler, vmms, MSExchangeTransport, MSExchangeIS) is installed and set to start automatically, as found over WinRM. Case does not matter. |
not: <condition> | The condition does not hold. |
all_of: [<condition>, ...] | Every condition in the list holds. |
any_of: [<condition>, ...] | At least one holds. |
Regular expressions use the Rust regex syntax, without look-around or back-references. Conditions nest at most 12 deep.
snmp_get
- snmp_get:
oid: 1.3.6.1.4.1.32473.2.2.0
op: starts
value: [ExampleOS]op | Holds when the value read |
|---|---|
eq, ne, lt, le, gt, ge | Compares with the first value. When either side is a number both are compared as numbers ("3" equals "3.0", and text reads as its leading number, or zero without one), otherwise as text. |
contains, starts, ends and not_contains, not_starts, not_ends | Contains, starts or ends with one of the values (or none of them). |
regex, not_regex | Matches one of the regular expressions (or none). |
in, not_in | Equals one of the values (or none). Numbers equal numbers only when both sides are numbers, so .v1 is not in ["0"]. |
exists | value: ["true"]: the object exists; ["false"]: it does not. |
A missing object compares as empty text, except for exists.
The objects are not read for every device. Discovery first matches every template with each snmp_get unknown, and reads objects only for the templates that could still match and whose outcome still depends on them, 16 to a request and at most 512 per device. A device that no such template could match costs no extra request.
Sensors
| Key | Meaning |
|---|---|
kind | A sensor kind from the sensor list. |
name | The sensor's name. {field} is replaced by its parameters and by what an expansion provides. |
params | The kind's parameters. |
when | Conditions that must all hold for this sensor to be proposed. |
expand | Proposes one sensor per row of something found on the device, see below. |
channel_limits | Limits by channel key, for example value: {warn_max: 40, error_max: 45}, replacing the kind's defaults. The operator can still change them. |
A device template cannot propose a combined sensor or a business process: they read other sensors by id, and a template is written before those sensors exist. Each has a sensor template of its own (name, what failure means, suggested interval 60 s and, for the business process, its four channels) that the "Add sensor" form uses.
Expansions
expand | One sensor per | Name placeholders |
|---|---|---|
snmp_interfaces | operational, non-loopback interface | {if_name} |
snmp_storage | fixed disk in the host resources storage table | {storage_descr} |
ssh_mounts | mount point of a real block device | {mount} |
ssh_services | running, enabled, well-known systemd service | {service} |
open_tcp_ports: {ports: [{port: 443, service: HTTPS}]} | listed port that was open | {service}, {port} |
windows_volumes | fixed volume | {volume} |
windows_adapters | physical network adapter that is connected, as the performance counters name it | {adapter} |
proxmox_nodes | online node of the Proxmox VE cluster | {node} |
proxmox_guests | guest (stopped guests and templates are proposed but not selected) | the guest's name is in the sensor's name |
proxmox_storages | enabled storage (a shared one once) | {storage} |
windows_replication_partners | domain controller that this one receives replication from, as repadmin /showrepl names it | {partner} |
vmware_hosts | connected host of the vSphere server (an ESXi host has only itself) | {host} |
vmware_datastores | datastore (inaccessible ones are proposed but not selected) | {datastore} |
vmware_vms | virtual machine (machines that are off and templates are proposed but not selected) | the machine's name is in the sensor's name |
windows_hyperv_vms | virtual machine of a Hyper-V host (machines that are off are proposed but not selected, and set not to expect running) | the machine's name is in the sensor's name |
docker_containers | container of the Docker host (stopped ones are proposed but not selected) | {container} |
windows_services | service that starts automatically and was running | {service} |
snmp_table: {...} | row of an SNMP table column | see below |
snmp_table
Reads a table column at discovery and proposes one sensor per row that passes. It is how imported LibreNMS definitions become sensors, and it works the same in your own templates.
- kind: snmp_custom_oid
name: "{descr} temperature"
params:
class: temperature
scale: 0.1
unit: °C
expand:
snmp_table:
value_column: 1.3.6.1.4.1.32473.2.3.1.3
columns:
descr: 1.3.6.1.4.1.32473.2.3.1.2
high: 1.3.6.1.4.1.32473.2.3.1.4
row_params:
oid: 1.3.6.1.4.1.32473.2.3.1.3.{index}
value: number
skip:
- { op: in, value: ["-1"] }
- { column: descr, op: eq, value: [""] }
limits: { error_max: high, scale: 0.1 }
fallback_name: Temperature {index}
max_rows: 64
channel_limits:
value: { warn_max: 40 }| Key | Default | Meaning |
|---|---|---|
value_column | required | The column, or a scalar object, whose rows decide which sensors exist. |
columns | none | Further columns read at discovery, by a name of your choice. |
row_params | none | Parameters filled in per row. {index} is the row index (3, 1.4), {subindex0}, {subindex1}, ... its parts, {count} the row's position from 1, and each name in columns that column's value in the same row. The same placeholders work in name. |
value | number | Which rows qualify: number needs a number, or text with a number in it; state a number or one of the labels of the sensor's value_map; any anything. |
skip | none | Rules that leave a row out. Each tests the row's value, or the column named, or the row index with index: true, using the snmp_get operators. |
limits | none | Limits read from columns, one column name per bound (error_min, warn_min, warn_max, error_max). Each is value * scale + offset, as for the reading. They apply to channel (default value) and win over channel_limits; when the two do not nest only the device's are kept, and when even those do not nest none are. |
fallback_name | none | The name when the rendered one is empty. |
max_rows | 128 | At most this many rows become sensors, 1 to 1024. |
Columns are walked only for primary templates that won and for add-ons that matched, at most 256 columns and 1024 rows each per device.