Page 1 of 1

Configuring Nagios Dependencies

Posted: Tue Jun 11, 2013 9:41 pm
by mspinzer
Hello,

I have some issue to configure dependencies in Nagios.
I did the following test on a totally new installation (Ubuntu 12.04 LTS):

Code: Select all

define service {                                           
        host_name                       localhost          
        service_description             Test_service_1     
        check_command                   test_service_1     
        use                             generic-service    
        check_interval           1                         
}                                                          
                                                           
define service {                                           
        host_name                       localhost          
        service_description             Test_service_2     
        check_command                   test_service_2     
        use                             generic-service    
        check_interval           1                         
}                                                          
                                                           
define servicedependency{                                  
        host_name                       localhost          
        service_description             Test_service_1     
        dependent_host_name             localhost          
        dependent_service_description   Test_service_2     
        execution_failure_criteria      c                  
        notification_failure_criteria   c                  
}                                                          
The services Test_service_1 and Test_service_2 are simple bash scripts that display the time and exit either with a code 0 (OK) or 2 (CRITICAL).
From what I understood, if Test_service_1 is in state CRITICAL, Test_service_2 should not be tested.
However, from the timestamp displayed in the output message, I can see that even when Test_service_1 is in CRITICAL, Test_service_2 is still tested.
Did I miss something?

Thanks a lot for your help,

Mike

Re: Configuring Nagios Dependencies

Posted: Wed Jun 12, 2013 1:25 pm
by abrist
mspinzer wrote:define servicedependency{
host_name localhost
service_description Test_service_1
dependent_host_name localhost
dependent_service_description Test_service_2
execution_failure_criteria c
notification_failure_criteria c
}
http://nagios.sourceforge.net/docs/3_0/dependencies.html wrote:In each definition you specify the dependent service, the service you are depending on, and the criteria (if any) that cause the execution and notification dependencies to fail (these are described later).
Essentially, the dependent service is the service that the actual service object depends on. Try switching your logic:

Code: Select all

define servicedependency{                                 
        host_name                       localhost         
        service_description             Test_service_2     
        dependent_host_name             localhost         
        dependent_service_description   Test_service_1     
        execution_failure_criteria      c                 
        notification_failure_criteria   c                 
}     

Re: Configuring Nagios Dependencies

Posted: Wed Jun 12, 2013 2:15 pm
by mspinzer
Hello,

thank you for your answer; I had actually tried both case:
- putting test1 in FAILED => test2 is still tested
- putting test2 in FAILED => test1 is still tested

so it seems something else is missing. Thanks again for your help, I really need to find a way to configure some dependencies.

Mike

Re: Configuring Nagios Dependencies

Posted: Thu Jun 13, 2013 2:23 pm
by sreinhardt
Did it continue to check, or was there already a check imminent that was about to be run on the dependent service? Often times these things are rather time sensitive and can seem a little wonky. (yup thats a real term)

Re: Configuring Nagios Dependencies

Posted: Fri Jun 14, 2013 3:46 pm
by mspinzer
Hello,

that was the problem, thanks! Nagios actually keep testing couple of times even if the dependency failed.
I guess this is because I configured the tests to run quite often for testing purpose (every minute).
However, I'm quite surprise that the Nagios engine can't react immediately. I don't know if this is inherent to the structure of the engine, but that would be great to have an immediate reaction when a dependency fails
Additionally, since the dependent test run again, it will go in a failed state, which generate lot of noise (and decrease the interest of the dependency mechanism). That would be really great to have the test going in a special "dependency failed" state so that it clearly appears from the dashboard that the test is not running anymore.

Anyway, thanks a lot for your help.

Mike