Master Agent setup doesnt seem to work

Hi All,

I am trying to setup a distributed system of icinga2 where i have one master and one agent. I had installed icinga2 and icingaweb2 on master which works perfectly fine. Now, i tried to add an agent/remote server which i want to monitor from the master i had previously setup.

I followed the node wizard setup process and did the master and agent setups in each of the machines.

Later, i added following in the conf.d/hosts.conf for the remote/agent machine:

object Zone "agent.domain" {
  endpoints = [ "agent.domain" ]
  parent = "master"
}
object Endpoint "agent.domain" {
  host = "ip-address of agent.domain"
}
object Host "agent.domain" {
  import "generic-host"
  address = "ip address of agent.domain"

  vars.systemd["cron"] = { friendly_name = "Cron Service", restart = false }

  vars.http_vhosts["http"] = {
    http_uri = "/"
  }
  /*  vars.disks["disk"] = {
    }*/
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }

  vars.http_vhosts["Icinga Web 2"] = {
   http_uri = "/icingaweb2"
  }

  vars.notification["mail"] = {
    groups = [ "icingaadmins" ]
  }
  vars.client_endpoint = name
}

Even if i bring down the cron service on agent machine, it still shows up and the same goes down when i bring down the cron service on master.

Is there anything i am missing ?

Below is the systemd command added in commands.conf

https://exchange.icinga.com/kiminen/icinga2-check_systemd_service

object CheckCommand "systemd_service" {
    command = [ PluginDir + "/check_systemd_service" ]

    arguments = {
      "--service_name" = {
        value = "$systemd_service_name$"
        description = "Name of systemd service for check"
        skip_key = true
        required = true
        order = 1
      },
      "--restart" = {
        set_if = "$systemd_restart$"
        description = "Restart service if is not running"
        required = false
        order = 2
    }
  }
}

You have not shown us the Service Check definition, but my guess is that you
have not defined “command_endpoint=host.name” to make the service check run on
the Agent instead of the Master.

PS: Always tell people which version of Icinga2 you are running - this can
make an important difference :slight_smile:

Regards,

Antony.

Hi, thanks for your reply.

the service check definition you mentioned refers to this ? Documentation of the plugin didnt had any command_endpoint.

apply Service for (service_name => config in host.vars.systemd) {
import “generic-service”

    check_command = "systemd_service"
    display_name = config.friendly_name
    vars.systemd_service_name = service_name
    vars.systemd_restart = config.restart

    assign where host.vars.systemd != null
}

Zone and endpoint objects can only be defined in zones.conf (if you are using V2.11).

My icinga version is 2.11.4-1
I have moved the zone configuration to zones.conf but still the issue persists.

I’d assume commands.conf is in /etc/icinga2/conf.d/? If so, it does not exist on your agent, hence, it could not be executed. New command object shall be placed in a global zone e.g. global-templates to be synchronized to every node.