1<a id="Working-with-agents"></a>Working with Agents and Config Zones
2====================================================================
3
4Working with Icinga 2 Agents can be quite tricky, as each Agent needs
5its own Endpoint and Zone definition, correct parent, peering host and
6log settings. There may always be reasons for a completely custom-made
7configuration. However, I'd strongly suggest to give the Director-assisted
8variant at least a try first. It might save you a lot of headaches.
9
10
11Preparation
12-----------
13
14Agent settings are not available for modification directly on a host
15object. This requires you to create an "Icinga Agent" template. You
16could name it exactly like that; it's important to use meaningful names
17for your templates.
18
19![Create an Agent template](screenshot/director/24-agents/2401_agent_template.png)
20
21As long as you're not using Satellite nodes, a single Agent zone is all
22you need. Otherwise, you should create one Agent template per satellite
23zone. If you want to move an Agent to a specific zone, just assign it
24the correct template and you're all done.
25
26
27Usage
28-----
29
30Well, create a host, choose an Agent template, that's it:
31
32![Create an Agent-based host](screenshot/director/24-agents/2402_create_agent_based_host.png)
33
34Once you import the "Icinga Agent" template, you'll see a new "Agent" tab.
35It tries to assist you with the initial Agent setup by showing a sample
36config:
37
38![Agent instructions 1](screenshot/director/24-agents/2403_show_agent_instructions_1.png)
39
40![Agent instructions 2](screenshot/director/24-agents/2404_show_agent_instructions_2.png)
41
42The preview shows that the Icinga Director would deploy multiple objects
43for your newly created host:
44
45![Agent preview](screenshot/director/24-agents/2405_agent_preview.png)
46
47
48Create Agent-based services
49---------------------------
50
51Similar game for services that should run on your Agents. First, create a
52template with a meaningful name. Then, define that Services inheriting from
53this template should run on your Agents.
54
55![Agent-based service](screenshot/director/24-agents/2406_agent_based_service.png)
56
57Please do not set a cluster zone, as this would rarely be necessary.
58Agent-based services will always be deployed to their Agent's zone by
59default. All you need to do now for services that should be executed
60on your Agents is importing that template:
61
62![Agent-based load check](screenshot/director/24-agents/2407_create_agent_based_load_check.png)
63
64Config preview shows that everything works as expected:
65
66![Agent-based service preview](screenshot/director/24-agents/2409_agent_based_service_rendered_for_host.png)
67
68It's perfectly valid to assign services to host templates. Look how the
69generated config differs now:
70
71![Agent-based service assigned to host template](screenshot/director/24-agents/2410_agent_based_service_rendered_for_host_template.png)
72
73While services added to a host template are implicitly rendered as
74assign rules, you could of course also use your `Agent-based service`
75template in custom apply rules:
76
77![Agent-based service applied](screenshot/director/24-agents/2411_assign_agent_based_service.png)
78
79
80
81