Skip to content

Hosts and templates

Status: verified

A host is a row: a name, an address, a way to be reached. A template is a bundle of questions and rules you link to a host instead of writing them one by one. The whole game of Zabbix administration is keeping those two ideas apart — add a machine once, link the knowledge once, and never let the two bleed into each other.

A host has a visible name (what the pages call it) and a technical name (what the agents and active checks answer to); for machines you control they are usually the same string. It belongs to a host group — the unit of who-may-see (chapter 9) and of the default dashboards — and it has interfaces: one or more addresses with a type and a port. The lab's host, created through the API, was exactly this small:

{"host": "lab-server", "interfaces": [{"type": 1, "main": 1, "useip": 1,
 "ip": "127.0.0.1", "dns": "", "port": "10050"}],
 "groups": [{"groupid": "2"}], "templates": [{"templateid": "10001"}]}

Interface type 1 is agent — the agent speaks on port 10050, the port the lab's agent was listening on. Group 2 is Linux servers, the stock group for the template that follows. The answer came back with hostid 10683 and one interface, id 31. From that one creation, the system is already asking questions — because of the last line.

The template is Linux by Zabbix agent (templateid 10001), the stock template for a Linux machine with the agent installed. Link it and you do not get one check, you get the whole bundle: the lab's host immediately owned 82 items — availability, processor load, memory, swap, disk space on the filesystems, network traffic, the agent's own version and hostname, the boot time — and the triggers that watch them, about processor load and memory and disk fullness and the host going dark. That is the point of templates: the project's engineers have already decided what a healthy Linux machine is supposed to look like, and you inherit their judgement with one link. Make the host first and link second and you watch nothing in between; link first (or in the same creation, as above) and the machine is watched from the first minute.

The same machinery explains why Zabbix scales to thousands of hosts without a thousand administrators: a template can itself be linked to templates, and when you edit a template — add a check, tighten a trigger — every linked host inherits the change. It also explains the temptation this guide warns against: editing a host's inherited item directly, where it will be silently overwritten by the template next time the template changes. Copy a template before customising it, or make a new one and link both. The distinction between "this host's own checks" and "the template's checks" is the one habit that keeps a large installation understandable.

Groups deserve one more sentence, because they are not folders: a group is the boundary of a user's view. The lab created, in chapter 9, a group of viewers allowed to read only the Linux servers group — and with that one permission the limited user saw exactly one host. Host groups are permissions machinery, not decoration; name them for the teams that will use them.

The check. A host exists when host.get names it, lists its interface, and shows the template in its parent list; the 82 items are the proof the link landed. In the lab transcript t05 the numbers follow in the same breath: agent.ping returns 1, agent.hostname returns lab-server, agent.version returns 7.0.32, the one-minute load returns a live figure. Four answers, four separate systems — server, agent, template, database — all agreeing.