Configuring Nagios Dependencies

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mspinzer
Posts: 3
Joined: Tue Jun 11, 2013 9:35 pm

Configuring Nagios Dependencies

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Configuring Nagios Dependencies

Post 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                 
}     
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mspinzer
Posts: 3
Joined: Tue Jun 11, 2013 9:35 pm

Re: Configuring Nagios Dependencies

Post 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
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Configuring Nagios Dependencies

Post 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)
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
mspinzer
Posts: 3
Joined: Tue Jun 11, 2013 9:35 pm

Re: Configuring Nagios Dependencies

Post 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
Locked