Possible to access host variables from NotificationCommand?

Hi,

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?

Thanks!

Hello @grifferz!

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

Best,
AK

2 Likes

Well, I feel silly now. Yes, that works. No idea what i was thinking of! Thanks!

Andy