Event Handling using monitoring status as condition.

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.

Event Handling using monitoring status as condition.

Postby doubleclick » Thu Dec 22, 2016 1:39 pm

Good Morning,

Is it possible to configure event handlers for hosts according to their monitoring status of disabled or enabled? I.e. If I disabled or activated monitoring for a host, could an event handler be triggered accordingly?

From what I've been reading it looks as if event handlers are very useful when using host states as conditions, but was wondering if the suppression status of a host could also be used as a condition?

If event handlers are not the way to go, would there be an alternative?

Thank you.
doubleclick
 
Posts: 7
Joined: Thu Dec 22, 2016 1:11 pm

Re: Event Handling using monitoring status as condition.

Postby mcapra » Thu Dec 22, 2016 2:19 pm

It would depend on the specific use case I suppose. Strictly speaking, if a Host/Service is not being monitored it's corresponding event handler should never execute:
https://assets.nagios.com/downloads/nag ... dlers.html

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


Could you describe the use case a little more in-depth?
Be sure to check out our Knowledgebase for helpful articles and solutions!

Want to see our Support Manager get thrown into a box? -- https://www.youtube.com/watch?v=pGSlqxIMxQM
User avatar
mcapra
Support Tech
 
Posts: 1562
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: Event Handling using monitoring status as condition.

Postby doubleclick » Thu Dec 22, 2016 2:47 pm

Thank you for your reply.

Indeed event handlers might not be the best option.

I've got monitoring services on a remote host. These services can only be suppressed/unsuppressed by running certain scripts. I'd like to use the nagios GUI to trigger these scripts, effectively disabling/enabling monitoring when I click the respective Nagios GUI buttons. (For this particular use case I cannot use nrpe.)
doubleclick
 
Posts: 7
Joined: Thu Dec 22, 2016 1:11 pm

Re: Event Handling using monitoring status as condition.

Postby avandemore » Thu Dec 22, 2016 4:23 pm

Have you looked at the External Commands feature?

https://assets.nagios.com/downloads/nag ... mands.html

Although I confess I'm puzzled by your use case since that functionality is already in the GUI.
User avatar
avandemore
Support Tech
 
Posts: 1021
Joined: Tue Sep 27, 2016 4:57 pm
Location: Nagios Enterprises

Re: Event Handling using monitoring status as condition.

Postby doubleclick » Thu Dec 22, 2016 7:34 pm

Apologies if I'm not explaining myself right,

When we use the nagios GUI to disable (or enable) monitoring, it is my understanding that in the background a certain instruction is triggered to write onto the command file, such as:
/bin/printf "[%lu] DISABLE_HOST_CHECK;host1\n" $now > $commandfile

(taken from here: https://old.nagios.org/developerinfo/ex ... mand_id=54 )

What I'd like to do (for a specific service of a remote host) is: when the Nagios GUI is used to disable/enable monitoring an instruction would be triggered to run one of my scripts instead.

The reason behind this is that I've got a remote host that contains services which are monitored by custom local scripts. I can locally and remotely prevent these scripts from running, thus disabling monitoring. Using the Nagios GUI to achieve this would be a lot nicer though. Admittedly, I guess this is not what nagios should be used for, however since I've got a few hosts in nagios it would be nicer to keep using Nagios and keep monitoring suppression/unsuppression in one place.

From what I read, external commands appear to be the opposite of what I'm trying to do - or perhaps I did not understand them correctly?
doubleclick
 
Posts: 7
Joined: Thu Dec 22, 2016 1:11 pm

Re: Event Handling using monitoring status as condition.

Postby rkennedy » Tue Dec 27, 2016 12:26 pm

I believe event handlers will work for this, however, you need to build a script to interpret the logic as @mcapra mentioned. Then, you can fine line execute whatever happens when x variables line up, such as execute the scripts on the local machine through check_by_ssh or check_nrpe.
Nagios Fusion 4 will be here soon! https://www.youtube.com/watch?v=Edc8ScCAYZk

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
rkennedy
Support Tech
 
Posts: 6495
Joined: Mon Oct 05, 2015 11:45 am
Location: Nagios Enterprises

Re: Event Handling using monitoring status as condition.

Postby doubleclick » Mon Jan 09, 2017 3:44 pm

Thank you for your help @rkennedy. Is there any nagios documentation you'd recommend on the topic of implementing a system that interprets the logic mentioned by @mcapra ? Looks as if I'll need to be working with a few background system files in order to be able to execute actions when host suppression status conditions are met, but not entirely sure where to start.
doubleclick
 
Posts: 7
Joined: Thu Dec 22, 2016 1:11 pm

Re: Event Handling using monitoring status as condition.

Postby dwhitfield » Mon Jan 09, 2017 4:28 pm

What version of Core are you using? Was it compiled from source or installed from distro repos? On what OS/version is nagios running? cat /etc/*-release may be of use.

All of that will help us give you the right documentation and potentially the right file paths.
https://support.nagios.com/forum/viewtopic.php?f=6&t=1274 says XI at the top, but it more-or-less applies to everything.
User avatar
dwhitfield
Support Tech
 
Posts: 1764
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: Event Handling using monitoring status as condition.

Postby rkennedy » Mon Jan 09, 2017 4:31 pm

The macros which will evaluate into the variables your after can be found here - https://assets.nagios.com/downloads/nag ... olist.html

I believe the specific ones you'll want to build your conditioning off of are $HOSTSTATE$ and $SERVICESTATE$.
Nagios Fusion 4 will be here soon! https://www.youtube.com/watch?v=Edc8ScCAYZk

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
rkennedy
Support Tech
 
Posts: 6495
Joined: Mon Oct 05, 2015 11:45 am
Location: Nagios Enterprises

Re: Event Handling using monitoring status as condition.

Postby doubleclick » Wed Jan 11, 2017 4:27 pm

Thank you @dwhitfield and @rkennedy.

Would there be macros similar to $HOSTSTATE$ and $SERVICESTATE$ that would evaluate against a host or service suppression status? This would really solve the problem.

The OS I'm using is RHEL Server release 5.3 and the Nagios version is 4.0.7.
doubleclick
 
Posts: 7
Joined: Thu Dec 22, 2016 1:11 pm

Next

Return to Nagios Core

Who is online

Users browsing this forum: javier_fuentes, Yahoo [Bot] and 26 guests