Page 1 of 1
Action triggered by alarm
Posted: Tue Feb 25, 2020 11:51 am
by dslaughter
I've been looking for a way to fire a script when a service goes into a bad state. I saw event handler examples and action links but I don't think that will provide the behavior I want. I want to do a http check and if it fails the script will fire and restart a service on the http server. I don't want to change the behavior of the http script itself. I could extend snmp on the http server or create an expect script that could login from nagiosxi to the http server. If I have to create a new service check based on the http test script I could do that. I just wanted to check to see if there is some kind of event/action feature I'm not aware of.
Re: Action triggered by alarm
Posted: Tue Feb 25, 2020 12:40 pm
by jdunitz
Really, it sounds like an event handler
would be just the thing here.
You wouldn't need to modify the behavior of the check command itself.
This guide is pretty good to provide a better understanding of how that works:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Actions also can accomplish something which is similar, yet different:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Also there are these documents outlining exactly how to do it
Windows –
https://assets.nagios.com/downloads/nag ... h_NRPE.pdf
Linux –
https://assets.nagios.com/downloads/nag ... h_NRPE.pdf
Does that help?
--Jeffrey
Re: Action triggered by alarm
Posted: Tue Feb 25, 2020 1:10 pm
by dslaughter
I've read all the documents you posted before I asked.
The event handler doc only uses a host for an example and changes the check to passive. I don't see how that will work with my service check. Maybe you can help me understand how it can work with a service instead of a host.
Actions looks like it just sets up a url to be used on quick actions. If you can show me how to tie that to a script instead of a url and how it triggers would be very helpful.
I'm working with linux only.
Re: Action triggered by alarm
Posted: Tue Feb 25, 2020 1:12 pm
by dslaughter
I forgot to add that I cannot use NRPE in this scenario. If I have to use an agent it has to be SNMP. I've extened SNMP with check scripts before instead of using NRPE.
Re: Action triggered by alarm
Posted: Tue Feb 25, 2020 2:28 pm
by benjaminsmith
Hello
@dslaughter,
You can run event handlers on both hosts and services, so the process is similar. In the CCM, find your service and go to the Check Settings tab to define the event handler.
event-handler.png
Event handlers are executed when a service or host:
* Is in a SOFT problem state
* Initially goes into a HARD problem state
* Initially recovers from a SOFT or HARD problem state
(see: The Nagios Core
Event Handler documentation for additional details ).
You can add macros to your script to fine-tune when the event handler will execute ( see page 12 of the Intro to Event Handlers guide).
As far as SNMP checks go, one way to solve this is to use check_by_ssh to execute the remote script. Let us know if that might work for you.
Monitoring Hosts Using SSH
Re: Action triggered by alarm
Posted: Wed Feb 26, 2020 1:40 pm
by dslaughter
Thanks, I'll start testing the options. Go ahead and lock this. If I need further help I'll open a new thread.
Re: Action triggered by alarm
Posted: Wed Feb 26, 2020 3:09 pm
by scottwilkerson
dslaughter wrote:Thanks, I'll start testing the options. Go ahead and lock this. If I need further help I'll open a new thread.
Great!
Locking