Two Event handler on same 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
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Two Event handler on same service

Post by anjali »

Hello Team,
I want to execute two event handler on the same service, one I need to execute when service is down and another I want to execute when service is again up.
So how I can achieve that? Please help me in that.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Two Event handler on same service

Post by eloyd »

One event handler for both things. If you read the event handler documentation (https://assets.nagios.com/downloads/nag ... dlers.html) you'll see that the event handler can be told if this is a CRITICAL (going down) or an OK (recovery/coming up) event. You would program your script to take different actions accordingly.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Two Event handler on same service

Post by anjali »

Hello,
But how I can get that event handler is executed for up or downstate in my custom script?
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Two Event handler on same service

Post by eloyd »

Read the documentation. Assigning the event handler will make it execute for every check performed. It's up to you to write the handler in such a way that it knows whether it is supposed to do something or not.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Two Event handler on same service

Post by scottwilkerson »

Eric is right, in the documentation he referenced https://assets.nagios.com/downloads/nag ... dlers.html you can see in the script you can put the code you want to execute in different parts of the example script to run on different state changes
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
anjali
Posts: 14
Joined: Wed May 29, 2019 6:23 am

Re: Two Event handler on same service

Post by anjali »

ok thanks, I achieve that by using service state in my custom script.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Two Event handler on same service

Post by scottwilkerson »

anjali wrote:ok thanks, I achieve that by using service state in my custom script.
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked