Action triggered by alarm

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dslaughter
Posts: 140
Joined: Wed Feb 20, 2019 3:46 pm

Action triggered by alarm

Post 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.
User avatar
jdunitz
Posts: 235
Joined: Wed Feb 05, 2020 2:50 pm

Re: Action triggered by alarm

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
dslaughter
Posts: 140
Joined: Wed Feb 20, 2019 3:46 pm

Re: Action triggered by alarm

Post 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.
dslaughter
Posts: 140
Joined: Wed Feb 20, 2019 3:46 pm

Re: Action triggered by alarm

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Action triggered by alarm

Post 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
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
dslaughter
Posts: 140
Joined: Wed Feb 20, 2019 3:46 pm

Re: Action triggered by alarm

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Action triggered by alarm

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked