Nagios check whether at least one out of two services is OK
I have two following passive services: ServiceA, ServiceB on one machine.
I would like to have a sittuation when the OK state is satisfied by following conditions:
- ServiceA is OK or ServiceB is OK
- ServiceA is OK and SericeB is OK
I would like to have alarm when:
- ServiceA is down and Service B is down
What configuration option should I use to implement that? Servicedependency looks good but I had no luck with that one.
check_cluster
is the "old school" way to do it, as mentioned already. But it's kludgy at best.
check_multi is a much better option for this; it is designed for exactly what you want.
This is known as monitoring a "cluster" of services. You can use the check_cluster script.
The documented method uses a wrapper script like this instead of calling it directly:
define command{
command_name check_service_cluster
command_line /usr/local/nagios/libexec/check_cluster --service -l $ARG1$ -w $ARG2$ -c $ARG3$ -d $ARG4$
}
and then defining your own specific service:
define service{
...
check_command check_service_cluster!"DNS Cluster"!1!2!$SERVICESTATEID:host1:dnsservicename,$SERVICESTATEID:host2:dnsservicename,$SERVICESTATEID:host3:dnsservicename
...
}
In this example 1/3 services not OK is a warning, 2/3 services not OK is a critical.
Nagios Docs
More explanation in Groundworks knowledge base