We’ve are having troubles to make “Service dependencies” feature work as described in Nagios user’s manual.
Our Scenario:
In order to avoid confusion, let’s consider an environment with an absolutely fresh install of Nagios with one single host being monitored. Let’s say that host has 2 services being monitored as well, PING and disk_space. If we make disk_space service dependent of ping service, results are odd depending on the order the services are scheduled to be tested in the queue.
For example: lets suppose the PING service is down and if by chance it was scheduled to be tested before disk_space, then service dependencies feature will work as expected every time, otherwise, if PING service is scheduled by chance to be tested after disk_space services, then the service dependencies testing logic will be completely ignored and both services will fail all times.
Our Goal:
Assure Nagios behave exactly as stated in its user manual; Please refer to information described on item “How Service Dependencies Are Tested” on nagios.sourceforge.net/docs/2_0/ … ncies.html
Follows a partial transcript of this document:
Before Nagios executes a service check or sends notifications out for a service, it will check to see if the service has any dependencies. If it doesn’t have any dependencies, the check is executed or the notification is sent out as it normally would be. If the service does have one or more dependencies, Nagios will check each dependency entry as follows:
- Nagios gets the current status* of the service that is being depended upon.
- Nagios compares the current status of the service that is being depended upon against either the execution or notification failure options in the dependency definition (whichever one is relevant at the time).
- If the current status of the service that is being depended upon matches one of the failure options, the dependency is said to have failed and Nagios will break out of the dependency check loop.
- If the current state of the service that is being depended upon does not match any of the failure options for the dependency entry, the dependency is said to have passed and Nagios will go on and check the next dependency entry.
This cycle continues until either all dependencies for the service have been checked or until one dependency check fails.
*One important thing to note is that by default, Nagios will use the most current hard state of the service(s) that is/are being depended upon when it does the dependeny checks. If you want Nagios to use the most current state of the services (regardless of whether its a soft or hard state), enable the soft_service_dependencies option.
***** HOSTS ************************************
define host {
name host-default
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}
define host {
use host-default
host_name HOST_A
address XXX.XXX.XX.X
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
contact_groups ADM
}
***** SERVICES *************************************
define service {
name service-default
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 0
retain_status_information 1
retain_nonstatus_information 1
register 0
}
define service {
use service-default
host_name HOST_A
service_description PING
check_period 24x7
max_check_attempts 3
normal_check_interval 1
retry_check_interval 1
contact_groups ADM
notification_interval 120
notification_period 24x7
notification_options w,c,r
check_command check_ping!900.0,50%!1200.0,80%
}
define service {
use service-default
host_name HOST_A
service_description DISK_C
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups ADM
notification_interval 120
notification_period 24x7
notification_options w,c,r
check_command check_disk!C!80%!95%
}
***** DEPENDENCIES *************************************
define servicedependency{
host_name HOST_A
service_description PING
dependent_host_name HOST_A
dependent_service_description DISK_C
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
}