Cannot unmarshal string into Go struct field Service.check_timeout of type float64

Hello dear community,

I have trouble finding out what causes this error in IcingaDB when I create certain hosts in the Director:

json: cannot unmarshal string into Go struct field Service.check_timeout of type float64

Full output of systemctl status icingadb:

icingadb.service - Icinga DB
 Loaded: loaded (/usr/lib/systemd/system/icingadb.service; enabled; vendor preset: disabled)
 Active: failed (Result: exit-code) since Fri 2023-06-09 07:47:41 CEST; 10min ago
Process: 112639 ExecStart=/usr/sbin/icingadb --config /etc/icingadb/config.yml (code=exited, status=1/FAILURE)
Main PID: 112639 (code=exited, status=1/FAILURE)

Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Inserting 14 items of type service
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Inserting 14 items of type service state
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Updating 238 items of type service state
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Inserting 58 items of type service customvar
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Deleting 11 items of type service customvar
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Aborted config sync after 145.542893ms
Jun 09 07:47:41 mgtmon214 icingadb[112639]: config-sync: Aborted initial state sync after 145.592056ms
Jun 09 07:47:41 mgtmon214 icingadb[112639]: json: cannot unmarshal string into Go struct field Service.check_timeout of type float64
                                        can't unmarshal JSON into *v1.Service
                                        github.com/icinga/icingadb/internal.UnmarshalJSON
                                                github.com/icinga/icingadb/internal/internal.go:47
                                        github.com/icinga/icingadb/pkg/icingaredis.CreateEntities.func1.1
                                                github.com/icinga/icingadb/pkg/icingaredis/utils.go:56
                                        golang.org/x/sync/errgroup.(*Group).Go.func1
                                                golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57
                                        runtime.goexit
                                                runtime/asm_amd64.s:1571
Jun 09 07:47:41 mgtmon214 systemd[1]: icingadb.service: Main process exited, code=exited, status=1/FAILURE
Jun 09 07:47:41 mgtmon214 systemd[1]: icingadb.service: Failed with result 'exit-code'.`

I’ve already found other threads about the “cannot unmarshal” error, but they looked to different from my problem.

What leads to this error:

Creating Host template WIN in Director:

template Host “WIN” {
import “Generic_host”

check_command = “hostalive-icmp”
icon_image = “windows.png”
icon_image_alt = “Windows Server”
vars.os = “WIN”
vars.os_version = “WIN_DEEP”
}

Imports the Generic_host:

template Host “Generic_host” {
vars.sla = “24x7”
}

Creating a host with this template in Director:

object Host “ABC_ABC123” {
import “WIN”

address = "127.0.0.1"
vars.cluster = false
vars.ic_client = "NSCP_0.4.4"
vars.notes = "test"
vars.prod = "TEST"
vars.sid = "GFE"
vars.typ = "RZ"

}

Right now, all services are applied using “apply Service…” in conf files outside of the Director, using assign rules such as

assign where match(“WIN”, host.vars.os)

I have done the exact same thing for a host template “LNX” and IcingaDB has no problem applying all services and writing in the DB. So I’m guessing that the problem is somewhere in a service that is only applied to hosts with vars.os=WIN. The error message doesn’t tell me exactly what the problematic service is. Is there a way to find this out other than applying every service separately and check when IcingaDB crashes?

Thanks in advance for any feedback.

  • Icinga DB Web version (System - About): 1.0.2
  • Icinga Web 2 version (System - About): 2.11.3
  • Web browser: Edge
  • Icinga 2 version (icinga2 --version): version: r2.13.7-1
  • Icinga DB version (icingadb --version): v1.1.0
  • PHP version used (php --version): PHP 7.4.33
  • Server operating system and version: SUSE Linux Enterprise Server 15 SP3

Hi,

the service itself is not mentioned, but a hint could be that you might have a check_timeout configured somewhere which holds a value with a fraction, instead of an absolute number.

Something like check_timeout = 10.0 should be changed to check_timeout = 10.

But please also open an issue over at Github so that the devs know about it.

Thank you, yes, there were timouts configured as strings in the conf files

check_timeout = “120”

I found all occurences with grep. Works fine now without the quotation marks!
Still, I wish the error message would tell me more :wink:

IcingaDB conversion of strings to number types, to avoid crashes · Issue #600 · Icinga/icingadb (github.com)

1 Like