Getting value for service from host

Hello everybody

How can I getting value for service from host? I need very much that.
I am tried a lot of things ($_host_environment$, $vars_environment$, $host_vars_environment$ etc.) :slight_smile: but I couldn’t it.

Try it with just the variable name, $environment$.
Works for me with “handing down” the $snmp_community$ variable

I am tried it earlier but this didn’t work for me.

Variable “environment” is type string

icingaweb2 version 2.7.0
icinga2 version 2.10.5
director version 1.6.2

Service:

That the $eonvironment$ variable is displayed at the “Custom VAriables” section is normal. You won’t see the content of the variable there.
image

Check the “Inspect” link and take a look what the field contains when the check is executed:
image

1 Like

environment variable only future tag of host not for command.

My Icinga of prod environment working without director and It is seem. Service conf and screenshot below:

I have no idea what you are trying to tell me, sorry.

The Icinga Director and the Icinga 2 conf files are two different pairs of shoes, as far as I know.
Have you checked what command line the Inspect link shows you, i.e what the core is trying to execute?

1 Like

Why you don’t use the REST-API from Icinga? There you see every var from a host. If needed you can parse the result in a script.
look here https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#querying-objects

Ok, I think I know now what you mean. You want to refefer from a variable in the Service to a variable in the host. This doesn’t work. My colleague found an old thread from Monitoring-Portal https://monitoring-portal.org/woltlab/index.php?thread/31327-icinga2-host-variablen-in-service-nutzen/ - sorry it’s in german. here @dnsmichi described why it’s not possible. I tried at yet and it doesnt’ work

1 Like