Referencing Object Types - Icinga 2 , I have a NotificationCommand
that looks like this:
env = {
ICINGA_HOSTNAME = "$host.name$"
ICINGA_HOSTOUTPUT = "$host.output$"
ICINGA_HOSTSTATE = "$host.state$"
# ... dozens of more lines...
}
Is there any way I can replace this with a for loop or such that would give me access to ALL of the host attributes - configuration and runtime - such that I could dynamically add them to the env? I can be flexible with the resulting key names. I’d then want to do the same for services.
I feel like I’d be able to do this in other languages, but I guess i don’t have a proper understanding of the data types, contexts, and evaluation order here to know if this is even possible. I did try adding a for loop to read from host
, but get an error:
critical/config: Error: Error while evaluating expression: Tried to access undefined script variable 'host'
… and trying to use macro("$host$")
results in a “Invalid field access” error.