Duplicate host entry points to self when adding agent

Hello,

Thank you everyone taking a look at this.

I’m trying to add a single agent “icinga-agent.internal.example.com” to a single master “icinga.hq”. I have completed exchanging cert information, added the zones and endpoints successfully, and am stuck adding the hosts.conf for remote command execution. I am following the documentation in Distributed Monitoring - Icinga 2 . I keep getting an error:

[2021-04-27 13:30:13 -0400] critical/config: Error: Object ‘icinga-agent.internal.example.com’ of type ‘Host’ re-defined: in /etc/icinga2/zones.d/master/hosts.conf: 13:1-13:52; previous definition: in /etc/icinga2/zones.d/master/hosts.conf: 13:1-13:52

/etc/icinga2/zones.d/master/hosts.conf

object Host “icinga-agent.internal.example.com” {
import “my-linux-host”
address = “10.2.2.3”

vars.agent_endpoint = name
}

There are no other host object definitions in any .conf file for ‘icinga-agent.internal.example.com’.

I have the following in my /etc/icinga2/icinga2.conf:

include “zones.conf”
include_recursive “zones.d”
// include_recursive “conf.d”

I have this host mentioned in the zones.conf file but as an Endpoint, not a Host object, and also as a Zone, following the documentation quite literally and just changing the host name.

Requested information:

/etc/icinga2/zones.conf:

object Endpoint “icinga.hq” {
host = “10.1.2.3”
}

object Endpoint “icinga-agent.internal.example.com” {
host = “10.2.2.3”
log_duration = 0 // Disable the replay log for command endpoint agents
}

object Zone “master” {
endpoints = [ “icinga.hq” ] //array with endpoint names
}

object Zone “icinga-agent.internal.example.com” {
endpoints = [ “icinga-agent.internal.example.com” ]

parent = “master” //establish zone hierarchy
}

object Zone “global-templates” {
global = true
}

# icinga2 --version

icinga2 - The Icinga 2 network monitoring daemon (version: r2.12.3-1)

Copyright (c) 2012-2021 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl2.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
Platform: Ubuntu
Platform version: 18.04.5 LTS (Bionic Beaver)
Kernel: Linux
Kernel version: 4.15.0-128-generic
Architecture: x86_64

Build information:
Compiler: GNU 8.4.0
Build host: runner-hh8q3bz2-project-298-concurrent-0
OpenSSL version: OpenSSL 1.1.1 11 Sep 2018

Application information:

General paths:
Config directory: /etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /run/icinga2

Old paths (deprecated):
Installation root: /usr
Sysconf directory: /etc
Run directory (base): /run
Local state directory: /var

Internal paths:
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid

# icinga2 feature list

Disabled features: compatlog debuglog elasticsearch gelf graphite icingadb influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker command ido-mysql mainlog notification

# icinga2 object list --type Endpoint

Object ‘icinga-agent.internal.example.com’ of type ‘Endpoint’:
% declared in ‘/etc/icinga2/zones.conf’, lines 12:1-12:56

  • __name = “icinga-agent.internal.example.com
  • host = “10.202.244.125”
    % = modified in ‘/etc/icinga2/zones.conf’, lines 13:3-13:25
  • log_duration = 0
    % = modified in ‘/etc/icinga2/zones.conf’, lines 14:3-14:18
  • name = “icinga-agent.internal.example.com
  • package = “_etc”
  • port = “5665”
  • source_location
    • first_column = 1
    • first_line = 12
    • last_column = 56
    • last_line = 12
    • path = “/etc/icinga2/zones.conf”
  • templates = [ “icinga-agent.internal.example.com” ]
    % = modified in ‘/etc/icinga2/zones.conf’, lines 12:1-12:56
  • type = “Endpoint”
  • zone = “”

Object ‘icinga.hq’ of type ‘Endpoint’:
% declared in ‘/etc/icinga2/zones.conf’, lines 8:1-8:27

  • __name = “icinga.hq”
  • host = “10.1.1.25”
    % = modified in ‘/etc/icinga2/zones.conf’, lines 9:3-9:20
  • log_duration = 86400
  • name = “icinga.hq”
  • package = “_etc”
  • port = “5665”
  • source_location
    • first_column = 1
    • first_line = 8
    • last_column = 27
    • last_line = 8
    • path = “/etc/icinga2/zones.conf”
  • templates = [ “icinga.hq” ]
    % = modified in ‘/etc/icinga2/zones.conf’, lines 8:1-8:27
  • type = “Endpoint”
  • zone = “”

You explicitly included the already implicitly included zones.d, so removing this line from your icinga2.conf will solve the problem.

1 Like

Thank you Dirk! That was the problem. Now I can move on.

I’m not a fan of implicit includes. I’m sure it’s documented somewhere, but a mix of explicit and implicit includes and special magic name directories leads to problems like this.

At least, if I see a duplicate error like this again, I’ll know it’s probably a duplicate include. (And I’ll pat myself on the back for including enough info to find the problem on the first go, LoL)

I totally understand that and have seen this error quite often because of this, but in this case it is required as it will load config directories dynamically based on zones configuration.