Conditionally trigger service

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
vlakshman
Posts: 27
Joined: Tue Aug 21, 2018 11:03 am

Conditionally trigger service

Post by vlakshman »

Team,

I want to trigger/call a service, say "Service B" running on "Host-H" when another service "Service A" running on "Host-H" enters a HARD - CRITICAL or RECOVERY.

I understand with Nagios Service Dependency, we can conditionally execute dependent service when Master Service is NOT in execution_failure_criteria or notification_failure_criteria.

define servicedependency{
host_name Host-H
service_description Service A
dependent_host_name Host-H
dependent_service_description Service-B
execution_failure_criteria w,u
notification_failure_criteria w,u
}

Above will trigger "Service B" when "Service A" is in "OK" or "CRITICAL" or "PENDING" state.
Is there a way to trigger it when "Service A" recovers?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Conditionally trigger service

Post by scottwilkerson »

vlakshman wrote:Is there a way to trigger it when "Service A" recovers?
Ok would be the same as recovers.

It is easier to think of the execution_failure_criteria as blocking execution rather than it triggering execution.

Nagios blocks execution from happening if the services is in the listed state, so in your example it would block execution if Service A is in WARNING or UNKNOWN, but would allow execution for any other.

If you want to run a script on a service recovery, you can look at event handlers
https://assets.nagios.com/downloads/nag ... dlers.html
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
vlakshman
Posts: 27
Joined: Tue Aug 21, 2018 11:03 am

Re: Conditionally trigger service

Post by vlakshman »

Scott,

execution_failure_criteria w,u
notification_failure_criteria w,u

In above case, blocking conditions for dependent service execution are when master service is in : WARNING or UNKNOWN
I understand when service recovers it enters OK state. If we don't specify OK in failure_criteria above, dependent service will execute when,

a) Master service is in OK state
b) Master service has recovered from NON-OK to OK state.

I want to specifically trigger my dependent service only when master service recovers.
Is there any way to specifically trigger dependent service ONLY on master service RECOVERY???



If we allow dependent service execution when Master service is in OK
Thanks for reply. I want to specifically trigger service execution ONLY on service RECOVERY.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Conditionally trigger service

Post by scottwilkerson »

vlakshman wrote:Is there any way to specifically trigger dependent service ONLY on master service RECOVERY???
Not in a dependency.
scottwilkerson wrote:If you want to run a script on a service recovery, you can look at event handlers
https://assets.nagios.com/downloads/nag ... dlers.html
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
vlakshman
Posts: 27
Joined: Tue Aug 21, 2018 11:03 am

Re: Conditionally trigger service

Post by vlakshman »

Thanks!

I think when everything about service is OK, Nagios marks the status as HARD, OK.
A service is said to be in "RECOVER' ing state, when it's in a SOFT, OK state right?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Conditionally trigger service

Post by scottwilkerson »

SOFT OK is used to note a services state if it is recovering from a SOFT non-OK state (one that never reached a HARD non-OK state), then will switch to a HARD OK at the next check.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked