Possible to access host variables from NotificationCommand?


I’m trying to access a variable from the relevant host inside a NotificationCommand object. So like:

Object NotificationCommand "some-notification-command" {
  command = [ SysconfDir + "/icinga2/scripts/some-notification-command.sh" ]

  env = {
    FOO = get_host("$host.name$").vars.foo

Now, I know vars.foo is set on the host, but when this NotificationCommand fires I always get an empty value in that environment variable. Is it not possible to access host custom variables in this way?

Do I have to do it as a script argument?


Hello @grifferz!

Have you tried FOO = "$host.vars.foo$"?