Agent setup: Cannot connect: Empty hostname

I’m trying to setup some CentOS 7 Icinga agents. The setup command fails (return code 1). The output tells me there is an empty hostname used. But why? According to documentation I’ve set everything correctly.

$ icinga2 node setup \
--zone l01bld06 \
--endpoint l01icinga,10.X.X.X,5665 \
--parent_host l01icinga,10.X.X.X,5665 \
--parent_zone master \
--listen 0.0.0.0,5665 \
--ticket `cat /var/cache/icinga2/my.ticket` \
--trustedcert /var/cache/icinga2/trusted.crt \
--cn l01bld06 \
--accept-config \
--accept-commands \
--disable-confd
information/cli: Requesting certificate with ticket 'bb61658d1cf41d1e3c144eec0da17d6259094181'.
information/cli: Verifying parent host connection information: host '', port '5665'.
information/cli: Using the following CN (defaults to FQDN): 'l01bld06'.
information/cli: Backup file '/var/lib/icinga2/certs//l01bld06.key.orig' already exists. Skipping backup.
information/cli: Backup file '/var/lib/icinga2/certs//l01bld06.crt.orig' already exists. Skipping backup.
information/base: Writing private key to '/var/lib/icinga2/certs//l01bld06.key'.
information/base: Writing X509 certificate to '/var/lib/icinga2/certs//l01bld06.crt'.
information/cli: Verifying trusted certificate file '/var/cache/icinga2/trusted.crt'.
information/cli: Requesting a signed certificate from the parent Icinga node.
critical/cli: Cannot connect to host '' on port '5665'
critical/cli: Failed to fetch signed certificate from parent Icinga node ', 5665'. Please try again.

Port to Icinga server is open:

$ nmap -P0 -p5665 l01icinga

Starting Nmap 6.40 ( http://nmap.org ) at 2021-06-10 11:39 CEST
Nmap scan report for l01icinga (10.X.X.X)
Host is up (0.0027s latency).
PORT     STATE SERVICE
5665/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

Whats wrong with my setup command?

DEBUG INFO

  • Version used (icinga2 --version): 2.12.3
  • Operating System and version: CentOS Linux release 7.9.2009 (Core)
  • Enabled features (icinga2 feature list)
Disabled features: api command compatlog debuglog elasticsearch gelf graphite icingadb influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notification
  • Icinga Web 2 version and modules (System - About): N/A
  • Config validation (icinga2 daemon -C)
[2021-06-10 11:31:19 +0200] information/cli: Icinga application loader (version: 2.12.3)
[2021-06-10 11:31:19 +0200] information/cli: Loading configuration file(s).
[2021-06-10 11:31:19 +0200] information/ConfigItem: Committing config item(s).
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 NotificationComponent.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 Host.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 Downtime.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 2 NotificationCommands.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 FileLogger.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 12 Notifications.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 IcingaApplication.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 2 HostGroups.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 CheckerComponent.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 3 Zones.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 Endpoint.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 235 CheckCommands.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 3 TimePeriods.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 UserGroup.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 User.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 11 Services.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 3 ServiceGroups.
[2021-06-10 11:31:19 +0200] information/ConfigItem: Instantiated 1 ScheduledDowntime.
[2021-06-10 11:31:19 +0200] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2021-06-10 11:31:19 +0200] information/cli: Finished validating the configuration file(s).
  • If you run multiple Icinga 2 instances, the zones.conf file (or icinga2 object list --type Endpoint and icinga2 object list --type Zone) from all affected nodes
# icinga2 object list --type Endpoint
Object 'l01bld06' of type 'Endpoint':
  % declared in '/etc/icinga2/zones.conf', lines 7:1-7:24
  * __name = "l01bld06"
  * host = "l01bld06"
    % = modified in '/etc/icinga2/zones.conf', lines 8:3-8:17
  * log_duration = 86400
  * name = "l01bld06"
  * package = "_etc"
  * port = "5665"
  * source_location
    * first_column = 1
    * first_line = 7
    * last_column = 24
    * last_line = 7
    * path = "/etc/icinga2/zones.conf"
  * templates = [ "l01bld06" ]
    % = modified in '/etc/icinga2/zones.conf', lines 7:1-7:24
  * type = "Endpoint"
  * zone = ""

# icinga2 object list --type Zone
Object 'director-global' of type 'Zone':
  % declared in '/etc/icinga2/zones.conf', lines 36:1-36:29
  * __name = "director-global"
  * endpoints = null
  * global = true
    % = modified in '/etc/icinga2/zones.conf', lines 37:3-37:15
  * name = "director-global"
  * package = "_etc"
  * parent = ""
  * source_location
    * first_column = 1
    * first_line = 36
    * last_column = 29
    * last_line = 36
    * path = "/etc/icinga2/zones.conf"
  * templates = [ "director-global" ]
    % = modified in '/etc/icinga2/zones.conf', lines 36:1-36:29
  * type = "Zone"
  * zone = ""

Object 'global-templates' of type 'Zone':
  % declared in '/etc/icinga2/zones.conf', lines 24:1-24:30
  * __name = "global-templates"
  * endpoints = null
  * global = true
    % = modified in '/etc/icinga2/zones.conf', lines 25:3-25:15
  * name = "global-templates"
  * package = "_etc"
  * parent = ""
  * source_location
    * first_column = 1
    * first_line = 24
    * last_column = 30
    * last_line = 24
    * path = "/etc/icinga2/zones.conf"
  * templates = [ "global-templates" ]
    % = modified in '/etc/icinga2/zones.conf', lines 24:1-24:30
  * type = "Zone"
  * zone = ""

Object 'l01bld06' of type 'Zone':
  % declared in '/etc/icinga2/zones.conf', lines 11:1-11:20
  * __name = "l01bld06"
  * endpoints = [ "l01bld06" ]
    % = modified in '/etc/icinga2/zones.conf', lines 12:3-12:26
  * global = false
  * name = "l01bld06"
  * package = "_etc"
  * parent = ""
  * source_location
    * first_column = 1
    * first_line = 11
    * last_column = 20
    * last_line = 11
    * path = "/etc/icinga2/zones.conf"
  * templates = [ "l01bld06" ]
    % = modified in '/etc/icinga2/zones.conf', lines 11:1-11:20
  * type = "Zone"
  * zone = ""

OK, I’ve found the cause after investigating the source code. Parameter --parent_host does not accept hosts in format “cn,host,port”. It accepts “host,port” or “host” only. This is not documented here: Distributed Monitoring - Icinga 2.

This worked:

$ icinga2 node setup \
--zone l01bld06 \
--endpoint l01icinga,10.X.X.X,5665 \
--parent_host l01icinga,5665 \
--parent_zone master \
--listen 0.0.0.0,5665 \
--ticket `cat /var/cache/icinga2/my.ticket` \
--trustedcert /var/cache/icinga2/trusted.crt \
--cn l01bld06 \
--accept-config \
--accept-commands \
--disable-confd