Page 1 of 1

Is it possible to have mutual dependencies for events?

Posted: Tue Mar 21, 2017 1:35 am
by aramisbackwards
I want to setup a network structure that works as below:

Code: Select all

Group 1
  (Main) Host 1 
  Host 2 
  Host 3

Group 2
  (Main) Host 4
  Host 5
  Host 6
What I want for this structure is for a notification / event_handler to be called if and only if all three hosts under a group are down/unreachable, else, simply default to single host
logic (which will probably have notifications disabled). All hosts in group 1 are up, and if only one or two are down there shouldn't be any notification. But if all three are down I want a notification sent AND I want to run an event_handler. Is it possible to have a dummy host or something that will never go down that depends on the three and can be forced down if those other three do?

Each host is monitored by check_host_alive / check_ping and I want to check the result of those check_pings/host_alives for the three hosts in the group.

If that isn't possible, should i try instead to define a host_dependency which calls checks for the other hosts if it goes into a critical state? If I want to call an event_handler for a custom script this seems to be non-trivial since there are two dependent hosts.



Should I be defining it instead as a Service which runs on the three hosts

Re: Is it possible to have mutual dependencies for events?

Posted: Tue Mar 21, 2017 12:26 pm
by mcapra
The short answer to your topic title is no.
Is it possible to have a dummy host or something that will never go down that depends on the three and can be forced down if those other three do?
I would define a separate service (or host) check to watch those 3 hosts in each group, then assign that service your "all 3 are down" handler. This would likely involve writing some sort of custom script to get the state of those 3 hosts. The JSON Query Generator would probably be handy for this:
http://<nagios_core_host>/nagios/jsonquery.html

You could also just bake that logic into your event handler for the 3 individual checks.