I what to create a simple(?) Notification with Icinga2 Director and send an email notification in case of two critical services, for example:
…assign where service.name == “exportPROD” && service.name == “exportPROD2”…
but I only receive a notification with using OR instead of AND with only one critical service.
I’d create a third service that is periodically evaluating those two services. Evaluate with get_service the
last_check_result and return state accordingly. Here you’ll find other example for using this function.
thanks for your hint. Unfortunately, I’m using the Icinga2 Web, which might be a poor solution, but I expect this “simple” Notification should do this job - but it doesn’t.
Your assign where rule never evaluates to true.
service.name = service1
service.name = service2
if its service1 than service1 != service2
if its service2 than service2 != service1
if else service3 != service1 and service 3 != service2
your way togo is indeed a third service that checks 2 other service results.
or if one service relys on the other you can use dependencies to surpress one notification.
To some more context:
The notification apply rule creates notification objects based on the assign where clause.
The outcome then are one (or more) notification objects, one for each host or service.
There is no relationship between those notifications, so the logic you want is not possible.
@rsx and @moreamazingnick presented two possible options to check that logic:
- new check that queries the api for the service states
A third option could be to use the check_multi script, with which you can run multiple commands as one check: GitHub - flackem/check_multi: the swiss knife Nagios plugin
There’s also the businessprocess module and
icingacli [help] businessprocess check as well as Icinga Template Library - Icinga 2