Runtime Exception creating new Host Template

Hi,

by creating a new host template with the director i got this exception:

ERROR - RuntimeException in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:853 with message: Storing director_datalist_entry[{"list_id":"2"}] failed: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entry_name' cannot be null, query was: INSERT INTO director_datalist_entry (list_id, entry_name, entry_value, format, allowed_roles) VALUES (?, ?, ?, ?, ?) {array (
  'list_id' => '2',
  'entry_name' => NULL,
  'entry_value' => NULL,
  'format' => NULL,
  'allowed_roles' => NULL,
)}

The template will be created anyway.

In addition when I use the icingacli to run the kickstart assistant i got a similar exception:

ERROR: RuntimeException in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:853 with message: Storing icinga_apiuser[] failed: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'object_name' cannot be null, query was: INSERT INTO icinga_apiuser (object_name, object_type, disabled, password, client_dn, permissions) VALUES (?, ?, ?, ?, ?, ?) {array (
  'id' => NULL,
  'object_name' => NULL,
  'object_type' => 'external_object',
  'disabled' => 'n',
  'password' => NULL,
  'client_dn' => NULL,
  'permissions' => NULL,
)}

The import over icingaweb2 works well.

Is there a way to fix the problem?

Thanks
Sebastian

Hi Sebastian,

welcome to the community :slight_smile:

What versions of icinga, icingaweb2 and the director are used here?
How are you creating the templates? With the Director GUI, API?
Please show an example.

1 Like

This is my environment:

Platform: CentOS Linux
Platform version: 8 (Core)
Kernel: Linux
Kernel version: 4.18.0-147.3.1.el8_1.x86_64
Architecture: x86_64
PHP Version: 7.2.11

icinga2 - The Icinga 2 network monitoring daemon (version: 2.11.2-1)

Icinga Web 2: 2.7.3

Loaded Module:

  • director 1.7.1
  • doc 2.7.3
  • fileshipper 1.1.0
  • grafana 1.3.6
  • incubator 0.5.0
  • ipl v0.4.0
  • monitoring 2.7.3
  • reactbundle 0.7.0
  • translation 2.7.3
  • vspheredb 1.1.0

I have created the templates with the Director GUI. Here is an example:

template Host "IP Based Device" {
    check_command = "hostalive"
    max_check_attempts = "3"
    check_interval = 1m
    retry_interval = 30s
    icon_image = "host.png"
}

template Host "Unix Host" { 
  import "IP Based Device" 

  icon_image = "tux.png" 
  vars.os = "linux" 
}

template Host "Test Template" { 
  import "Unix Host" 
}

Thank you for your quick response!

For running the kickstart command from the CLI you need a kickstart.ini file:

# icingacli director kickstart run --help
Trigger the kickstart helper
============================

This will connect to the endpoint configured in your kickstart.ini,
store the given API user and import existing objects like zones,
endpoints and commands.

/etc/icingaweb2/modules/director/kickstart.ini could look as follows:

   [config]
   endpoint = "master-node.example.com"

   ; Host can be an IP address or a hostname. Equals to endpoint name
   ; if not set:
   host = "127.0.0.1"

   ; Port is 5665 if none given
   port = 5665

   username = "director"
   password = "***"

if you do the whole thing via the web interface the director will ask these information to be input by you.

Why you get the error message via the GUI I can’t really say.
Maybe it is gone after doing the kickstart?
You can also do the kickstart via the GUI and put the needed information there. No need for a kickstart.ini then

1 Like

Thank you! After I create the kickstart.ini the icingacli director kickstart is working.

And I found a solution (or a bug?) that solves the problem with the template creation.
By creating a template over the GUI i receive this message:

Storing director_datalist_entry[{"list_id":"7"}] failed: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entry_name' cannot be null, query was: INSERT INTO director_datalist_entry (list_id, entry_name, entry_value, format, allowed_roles) VALUES (?, ?, ?, ?, ?) {array ( 'list_id' => '7', 'entry_name' => NULL, 'entry_value' => NULL, 'format' => NULL, 'allowed_roles' => NULL, )} (DbObject.php:853)`

I found in the table director_datalist_entry this tuple:

|       7 | windows7Server64Guest | Microsoft Windows Server 2008 R2 (64-bit)       | string | NULL          |
|       7 | windows8Server64Guest | Microsoft Windows Server 2012 (64-bit)          | string | NULL          |
|       7 | windows9Server64Guest | Microsoft Windows Server 2016 or later (64-bit) | string | NULL          |

By creating the template i leave the custom attribute (winver) empty and the exception is triggered. I would only have set the attribute on the host object. But when i set the attribute on the template the exception is not triggered. I am not sure this is the correct behavior?

template Host "Test Template" { 
  import "Windows Host" 

  vars.winver = "windows9Server64Guest" 
}