Conditionally trigger service

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Conditionally trigger service

Postby vlakshman » Wed Aug 14, 2019 10:21 am

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

Re: Conditionally trigger service

Postby scottwilkerson » Thu Aug 15, 2019 7:03 am

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/nagioscore/docs/nagioscore/4/en/eventhandlers.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Conditionally trigger service

Postby vlakshman » Fri Aug 16, 2019 12:07 am

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

Re: Conditionally trigger service

Postby scottwilkerson » Fri Aug 16, 2019 6:30 am

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Conditionally trigger service

Postby vlakshman » Mon Aug 19, 2019 1:35 am

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

Re: Conditionally trigger service

Postby scottwilkerson » Mon Aug 19, 2019 6:48 am

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15796
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot], ssax and 13 guests