Pin Check to Satellite instead of Agent

Hi,

is it possible to pin some checks to the satellite and not to the agent?

Before I installed the Director, I had set the entry “zone=” in the host configuration. Unfortunately, this is not possible in the Direcotor, otherwise it also changes the scope from zones.d//hosts.conf to zones.d//hosts.conf.

Kind regards
Robert

Hi,
sure it’s possible in the director. You have to create a template where you set this. If you switch the opton “run on agent” to “yes” the check is running on the agent, if you set no or nothing, it’s running on the satellite from that zone, where the host is assigned to.

Hi Stevie,

it’s a little more complex so this solution doesn’t work for me. I have a master ß Satellite <-> Agent Setup.

Also when i set this option, every check running on the agent.

Hi,

we have 2 master, 4 satellites - in 2 zones and a lot of agents. And I can assure you that it works :wink: As I wrote, if you don’t set this option icinga tries to run to check this on the agent.

We often have to set up new check commands for script, which colleagues wrote on their own on their servers. It happens often to us, that we choose the wrong template. So the satellite tries to run the defined script behind the check command. And of course the stallite don’t find it. It happened to us also the other way around. What I want to say is to fix this was always the switch “Run on agent” with “yes” or “no” in the template…

Hi Stevie,

Happy New Year and sorry for the delay. :slight_smile:
Unfortunately, the problem still exists and i dont know why?!?

Here is my config:

On the master:

zones.d/master/zones.conf

object Zone "pp-inf-mon-01.satellite.com" {
    parent = "master"
    endpoints = [ "pp-inf-mon-01" ]
}

object Zone "master" {
    endpoints = [ "monitor.master.com" ]
}

zones.d/master/hosts.conf

object Host "monitor.master.com" {
    import "l.host"

    address = "127.0.0.1"
    vars.no_swap = true
}

zones.d/master/endpoints.conf

object Endpoint "pp-inf-mon-01.satellite.com" {
    host = "192.168.0.12"
    port = "5665"
}

zones.d/pxe.agent.com/hosts.conf

object Host "pxe.agent.com" {
    import "g.host"

    address = "pxe.agent.com"
    vars.os = "windows"
}

zones.d/pp-inf-mon-01.satellite.com/zones.conf

object Zone "pxe.agent.com" {
    parent = "pp-inf-mon-01.satellite.com"
    endpoints = [ "pxe.agent.com" ]
}

On the Satellite:

/etc/icinga2/zones.conf

object Endpoint "monitor.master.com" {
        host = "monitor.master.com"
        port = "5665"
}

object Zone "master" {
        endpoints = [ "monitor.master.com" ]
}

object Endpoint "pp-inf-mon-01.satellite.com" {
}

object Zone "pp-inf-mon-01.satellite.com" {
        endpoints = [ "pp-inf-mon-01.satellite.com" ]
        parent = "master"
}

/var/lib/icinga2/api/zones/pp-inf-mon-01.satellite.com/director/endpoints.conf

object Endpoint "pxe.agent.com" {
    host = "pxe.agent.com"
    port = "5665"
}

/var/lib/icinga2/api/zones/pp-inf-mon-01.satellite.com/director/zones.conf

object Zone "pxe.agent.com" {
    parent = "pp-inf-mon-01.satellite.com"
    endpoints = [ "pxe.agent.com" ]
}

On the Agent:

C:\Programdata\icinga2\etc\icinga2\zones.conf

object Endpoint "pp-inf-mon-01.satellite.com" {
	host = "pp-inf-mon-01.satellite.com"
	port = "5665"
}

object Zone "master" {
	endpoints = [ "pp-inf-mon-01.satellite.com" ]
}

object Endpoint "pxe.agent.com" {
}

object Zone "pxe.agent.com" {
	endpoints = [ "pxe.agent.com" ]
	parent = "master"
}

Service-Template

zones.d/director-global/service_templates.conf

template Service "test" {
    max_check_attempts = "3"
    check_interval = 1m
    retry_interval = 30s
    command_endpoint = null
}

Service

zones.d/director-global/service_apply.conf

apply Service "test-ping" {
    import "test"

    check_command = "ping"
    assign where host.name == "pxe.agent.com"

    import DirectorOverrideTemplate
}

The Result

The Check-Source is always the host itself and not the Satellite.

Kind regards,
robse

Hi Robert,

i guess that happens because your host “pxe.agent.com” is assigned to the zone “pxe.agent.com” (via zones.d/pxe.agent.com/hosts.conf). If you place the host config file inside of the satellite directory (i. e. zones.d/pp-inf-mon-01.satellite.com/hosts.conf) the check should be executed from the satellite zone.

Kind regards,
ritzgu

1 Like

Hi ritzgu,

this solved my Problem.

But the first step is to create the agent in its own zone. The agent can then be deactivated and switched to the satellite zone. Finally, the agent can be reactivated.

If I do it differently, the agent doesn’t get any configuration. Now everything works as expected.

Many Thanks. :slight_smile:

1 Like