Read service output to pass to event handler script

Hi all,

Is it possible to read the output of a specific service and pass it as argument to
a script (event handler or not it’s the same I believe) ?

Cheers,
Mike

yes e.g.:

vars.icinga_last_output = {{get_service("", “”).last_check_result.output}}

Thank you!
Is this somewhere in the docs?

Yes e.g. in the table Runtime Attributes of Service Objects.

Can these functions work in the director too?
Because I am trying to pass what you posted above in a var but I am not
sure if it works. I tried getting the state of the service even and it still returns the output.

Edit: They can if you set the value type as Icinga DSL

You can pass the service output to the command by using “$service.output$”.
This also is possible in the director and even with more vars, we are doing that, too :wink:
We also use these ones, so you might give it a shot: $host.name$ $host.address$ $service.name$ $service.state$ $service.state_type$ $service.check_attempt$ $service.output$

1 Like

Ah yes I had forgot about that even though I used it many times.
Thanks for the reminder!