# Multiple Icinga agent instances on one host

**URL:** <https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019>\
**Category:** Icinga 2\
**Tags:** icinga2\
**Created:** [January 18, 2022, 6:00pm UTC](https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019 "2022-01-18T18:00:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewgegg](https://community.icinga.com/user_avatar/community.icinga.com/lewgegg/32/5090_2.png) [@lewgegg](https://community.icinga.com/u/lewgegg)\
**Post date:** [January 18, 2022, 6:00pm UTC](https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019/1 "2022-01-18T18:00:06Z")

</div>

Hello,

Is it possible to run multiple Icinga client instances on the same host?  
I can see that this is supported in theory: [Distributed Monitoring - Icinga 2](https://icinga.com/docs/icinga-2/latest/doc/06-distributed-monitoring/#using-multiple-environments)

I have an environment where monitored hosts are sitting in their own isolated networks. These networks also contain hosts that only allow SNMP requests from the local network (and can’t run any other software). At the same time, I don’t want to have every isolated network host showing up as one host in Icinga.

So my solution would be to use multiple Icinga instances so that I can get the hosts to show up as individual hosts rather than one host with many unrelated services.

If the multiple instance Icinga feature is still under development, is there any way to separate out services being checked on one host into many hosts? I’d like to retain the ability to centrally modify the configuration via Director which rules NRPE, NSCA, NRDP, NSCP, NCPA out.

I can see similar questions asked in these threads, but there isn’t a clear way to implement this:

> [@Icinga2 add dynamically Oracle instance as a child host](https://community.icinga.com/t/icinga2-add-dynamically-oracle-instance-as-a-child-host/7267):
>
> Hello, I’m using Icinga2 to monitor our linux and windows servers. Distributed monitoring has been configured - one master server and multiple agents. I would like to monitor oracle instances as well. In our configuration we have multiple instances running on the same linux host. For each linux host, there is a host definition in hosts.conf Now I would like to add oracle instances to the icinga2 configuration. What’s here the best practice? I was considering adding oracle instance as a hos…

> [@Multiple Icinga Agents on same](https://community.icinga.com/t/multiple-icinga-agents-on-same/8233):
>
> Hello Icinga community o/ Could I run multiple Icinga2 agent environments ? Actually I want to run on the same node, two different icinga2 agent configurations. Is such a thing possible ? I have two completely different Icigna 2 master setups ( eg: : two different organizations/companies ) and each one wants to do their own agent checks. I tried the following… Create CSR and Certificate for the node. icinga2 pki new-cert --cn icinga-agent.example \ --key /var/lib/icinga2/certs/icinga-age…

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [January 18, 2022, 8:10pm UTC](https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019/2 "2022-01-18T20:10:24Z")

</div>

sounds like a really bad idea to run multiple agents on one host.

if you use the icinga director you can try the master branch and activate the endpoint feature.  
than you can create multiple hosts which access one agent.

> [@Force command endpoint for specific service (i.e. to agent associated with other host object)](https://community.icinga.com/t/force-command-endpoint-for-specific-service-i-e-to-agent-associated-with-other-host-object/7434):
>
> We have a setting with hosts hosting services for different customers: Physical Host “phyhost” service A: customer 1 service B: customer 2 To handle downtimes on a per customer basis we created following setup in director: Physical Host “phyhost” (agent based monitoring) - a lot of service checks relevant for the host itself “Hosted Host” “cust1host” object name is phyhost\_cust1host, the address is the address of “phyhost” “Hosted Host” “cust2host” object name is phyhost\_cust1hos…

or you wait till it gets released.

best regards Nicolas

---

<div class="post-metadata">

**Author:** ![otl](https://community.icinga.com/user_avatar/community.icinga.com/otl/32/5229_2.png) [@otl](https://community.icinga.com/u/otl)\
**Post date:** [January 19, 2022, 1:15am UTC](https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019/3 "2022-01-19T01:15:43Z")

</div>

Here’s an approach which worked for me, @davekempe and others at [sol1](https://sol1.com.au) in similar environments to what you’ve described.

> I’d like to retain the ability to centrally modify the configuration via Director

If I remember correctly this approach should work fine with Director. But instead of writing text files you’re clicking around in the GUI to set variables etc.

## Briefly

We would run an Icinga2 agent on a host in each network. On each Service, we set `command_endpoint` the name of the agent.

## Detailed

Here’s an example setup.

Our 2 networks are in Sydney and Rotterdam. In each network, an Icinga2 agent is running on a host. That agent can connect to each device via SNMP.

Define the endpoints in each network:

```
object Endpoint "icinga.sydney.example.com" { ... }
object Endpoint "icinga.rotterdam.example.com" { ... }

```

A Service which checks something over SNMP:

```
apply Service "snmp_example" {
	check_command = "snmp"
	vars.snmp_oid = "1.2.3.4.5.6.7.8.9"
	command_endpoint = host.vars.agent_endpoint
}

```

Setting `command_endpoint` means that the agent executes the SNMP command rather than the master Icinga server.

Finally, define the hosts from each network, setting the `agent_endpoint` variable to the agent that is available in the particular network.

```
object Host "device1" {
	address = "192.0.2.1"
	vars.agent_endpoint = "icinga.sydney.example.com"
}
object Host "device2" {
	address = "192.0.2.2"
	vars.agent_endpoint = "icinga.sydney.example.com"
}
object Host "device3" {
	address = "198.51.100.1"
	vars.agent_endpoint = "icinga.rotterdam.example.com"
}
object Host "device4" {
	address = "198.51.100.2"
	vars.agent_endpoint = "icinga.rotterdam.example.com"
}
...

```

In this example, devices 1 and 2 are in the Sydney network. Devices 3 and 4 are in Rotterdam.

For another explanation of this approach, see the [Icinga blog post on command endpoints](https://icinga.com/blog/2020/06/24/using-command-endpoint-to-execute-checks-on-agents/).

Hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![lewgegg](https://community.icinga.com/user_avatar/community.icinga.com/lewgegg/32/5090_2.png) [@lewgegg](https://community.icinga.com/u/lewgegg)\
**Post date:** [January 21, 2022, 6:25pm UTC](https://community.icinga.com/t/multiple-icinga-agent-instances-on-one-host/9019/4 "2022-01-21T18:25:22Z")

</div>

> [@otl](#):
>
> ```auto
> object Host "device1" {
> address = "192.0.2.1"
> vars.agent_endpoint = "icinga.sydney.example.com"
> }
> 
> ```

Thank you so much @otl , that worked! It doesn’t seem to be possible to change command\_endpoint in Director, but your solution works very well.
