Page 1 of 1

Nagios Core External Commands - Event Handlers

Posted: Mon Aug 26, 2019 10:45 am
by FrontlineIT
Hello,

I've been using Powershell to disable/enable event handlers globally across our Nagios XI instance using the External Core Commands. Is there a Core Command or a way to disable/enable event handlers for a particular host/service group? Below is what I'm using to disable event handlers globally via Powershell, any examples of doing something similar but just for a specified host/service group would be greatly appreciated.

Invoke-RestMethod -Method Post -Uri "http://**********/nagiosxi/api/v1/system/corecommand?apikey=***********" -Body "cmd=DISABLE_EVENT_HANDLERS"

Re: Nagios Core External Commands - Event Handlers

Posted: Mon Aug 26, 2019 12:29 pm
by eloyd
I don't specifically know of a way to disable it for a host/service, but you could write your event handler(s) to look for a local lock file on the Nagios system. If lock file exists, then exit handler. Then you could make a quick PHP/Perl/Python/Bash/whatever web script that takes service, host, and maybe an API key, verifies you, and then creates/deletes the lock file through the Apache web server.

This way, a CURL request would create/delete the lock file, and the event handler would exit/proceed accordingly.

Re: Nagios Core External Commands - Event Handlers

Posted: Mon Aug 26, 2019 12:41 pm
by mbellerue
Thanks for jumping in, Eric!

FrontlineIT, would Eric's solution work for your setup?

Re: Nagios Core External Commands - Event Handlers

Posted: Tue Aug 27, 2019 7:13 am
by FrontlineIT
Thanks for the idea but we have a bunch of different event handlers scattered across thousands of servers so that would be tough. Was hoping there would be an external core command similar to "DISABLE_HOSTGROUP_SVC_NOTIFICATIONS". The end goal is to be able to disable alerts and event handlers for a particular group of servers serving an application. The alerts portion is covered already with the command pointed out above. It would be nice, for example, if there was a command named something like "DISABLE_HOSTGROUP_SVC_EVENT_HANDLERS".

Re: Nagios Core External Commands - Event Handlers

Posted: Tue Aug 27, 2019 7:16 am
by eloyd
Event handlers run on the Nagios server. Do you have thousands of Nagios servers?

Re: Nagios Core External Commands - Event Handlers

Posted: Tue Aug 27, 2019 7:56 am
by FrontlineIT
Sorry, I may have misunderstood. I was thinking of the custom plugins/scripts the event handlers reach out to execute on the target hosts.

Re: Nagios Core External Commands - Event Handlers

Posted: Tue Aug 27, 2019 7:58 am
by FrontlineIT
The lock file route may be tough because we have generic event handlers that are used by multiple apps/servers which is why I was hoping to use host groups/service groups.

Re: Nagios Core External Commands - Event Handlers

Posted: Tue Aug 27, 2019 4:27 pm
by tgriep
Take a look at this site with a list of the Nagios External Commands.
https://assets.nagios.com/downloads/nag ... ernalcmds/

There are commands for enabling or disabling Event Handlers for Host and Services but there is not one for Hostgroups.
ENABLE_SVC_EVENT_HANDLER
DISABLE_SVC_EVENT_HANDLER
ENABLE_HOST_EVENT_HANDLER
DISABLE_HOST_EVENT_HANDLER
Bad news is that there is not a way to do that by groups so you have to write a script to get the services and then run the external command for each service.

Re: Nagios Core External Commands - Event Handlers

Posted: Wed Aug 28, 2019 7:44 am
by FrontlineIT
Thank you. I will take a stab at that. This forum can be closed.