Would event-handler get disabled with scheduled downtime
Would event-handler get disabled with scheduled downtime
Hello XI Support
We had configured Windows Service event handling (start back if stopped)
as per https://assets.nagios.com/downloads/nag ... 1454484852
Please advice if scheduled downtime (host or service) would prevent event handler from triggering service startup (as it hopefully should)
- we need the way to disable event handling during server/services maintenance (done by users, not via service deactivations)
Thank you
We had configured Windows Service event handling (start back if stopped)
as per https://assets.nagios.com/downloads/nag ... 1454484852
Please advice if scheduled downtime (host or service) would prevent event handler from triggering service startup (as it hopefully should)
- we need the way to disable event handling during server/services maintenance (done by users, not via service deactivations)
Thank you
Re: Would event-handler get disabled with scheduled downtime
I just answered this question another thread recently.
Short answer is no, event handlers remain active during scheduled downtime. But, you can write logic into your event handler scripts so they will not run if downtime is detected. This is accomplished by using the $HOSTDOWNTIME$ and/or $SERVICEDOWNTIME$ macros in your event handler definitions. If these macros are non-zero, then the service/host is considered to be in scheduled downtime. This will allow you to have your event handlers decide how to proceed.
Two other options (not ideal, do these for the duration of the scheduled downtime)
- Disable all event handlers globally in nagios.cfg = enable_event_handlers
- Disable event handler at the host or service level, check for 'event_handler = enabled' in the definition.
Understanding Macros and How They Work
https://assets.nagios.com/downloads/nag ... acros.html
Short answer is no, event handlers remain active during scheduled downtime. But, you can write logic into your event handler scripts so they will not run if downtime is detected. This is accomplished by using the $HOSTDOWNTIME$ and/or $SERVICEDOWNTIME$ macros in your event handler definitions. If these macros are non-zero, then the service/host is considered to be in scheduled downtime. This will allow you to have your event handlers decide how to proceed.
Two other options (not ideal, do these for the duration of the scheduled downtime)
- Disable all event handlers globally in nagios.cfg = enable_event_handlers
- Disable event handler at the host or service level, check for 'event_handler = enabled' in the definition.
Understanding Macros and How They Work
https://assets.nagios.com/downloads/nag ... acros.html
Be sure to check out the Knowledgebase for helpful articles and solutions!
Re: Would event-handler get disabled with scheduled downtime
Well, event handler is one of yours from assets:bwallace wrote:I just answered this question another thread recently.
Short answer is no, event handlers remain active during scheduled downtime. But, you can write logic into your event handler scripts so they will not run if downtime is detected. This is accomplished by using the $HOSTDOWNTIME$ and/or $SERVICEDOWNTIME$ macros in your event handler definitions. If these macros are non-zero, then the service/host is considered to be in scheduled downtime. This will allow you to have your event handlers decide how to proceed.
Two other options (not ideal, do these for the duration of the scheduled downtime)
- Disable all event handlers globally in nagios.cfg = enable_event_handlers
- Disable event handler at the host or service level, check for 'event_handler = enabled' in the definition.
Understanding Macros and How They Work
https://assets.nagios.com/downloads/nag ... acros.html
File: servicer~tart.sh Line 1 Col 0 227 bytes 100%
#!/bin/sh
# Event Handler for Restarting Linux/BSD/Windows Services
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c runcmd -a "$3"
;;
esac
exit 0
Could you please help us to get it working with scheduled downtimes?
Re: Would event-handler get disabled with scheduled downtime
Here you go....
The command in XI should be changed to this:
check_nrpe -H $HOSTADDRESS$ $ARG2$ -p -c runcmd -a $ARG3$ $ARG4$
And the script should now look like:
Only thing that's new in the script are those 1st 3 UNcommented lines:
The command in XI should be changed to this:
check_nrpe -H $HOSTADDRESS$ $ARG2$ -p -c runcmd -a $ARG3$ $ARG4$
And the script should now look like:
Code: Select all
#!/bin/sh
# Event Handler for Restarting Linux/BSD/Windows Services
if [$4 -gt 0]
then exit
fi
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c runcmd -a "$3"
;;
esac
exit 0
Code: Select all
if [$4 -gt 0]
then exit
fiBe sure to check out the Knowledgebase for helpful articles and solutions!
Re: Would event-handler get disabled with scheduled downtime
Hibwallace wrote:Here you go....
The command in XI should be changed to this:
check_nrpe -H $HOSTADDRESS$ $ARG2$ -p -c runcmd -a $ARG3$ $ARG4$
And the script should now look like:Only thing that's new in the script are those 1st 3 UNcommented lines:Code: Select all
#!/bin/sh # Event Handler for Restarting Linux/BSD/Windows Services if [$4 -gt 0] then exit fi case "$1" in OK) ;; WARNING) ;; UNKNOWN) ;; CRITICAL) /usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c runcmd -a "$3" ;; esac exit 0Code: Select all
if [$4 -gt 0] then exit fi
This did not work (updated handling script, scheduled downtime, but handler still restarts the services)
Should we make a ticket out of this one?
Re: Would event-handler get disabled with scheduled downtime
Did you use $SERVICEDOWNTIME$ or $HOSTDOWNTIME$? If you used $SERVICEDOWNTIME$ was the service in downtime or just the host?
Please post your command definition as well so that we may review it.
Thank you
Please post your command definition as well so that we may review it.
Thank you
Re: Would event-handler get disabled with scheduled downtime
I think I missed this one. How to use it?ssax wrote:Did you use $SERVICEDOWNTIME$ or $HOSTDOWNTIME$? If you used $SERVICEDOWNTIME$ was the service in downtime or just the host?
Please post your command definition as well so that we may review it.
Thank you
$USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 12489 -v $ARG2$ $ARG3$ $ARG4$
Re: Would event-handler get disabled with scheduled downtime
The changes for this have to be added to the event handler script called service_restart. Try editing like the example below and see if that works for you.
Code: Select all
define command {
command_name service_restart
command_line $USER1$/servicerestart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$ $SERVICEDOWNTIME$
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Would event-handler get disabled with scheduled downtime
This is still not working / creating ticket insteadtgriep wrote:The changes for this have to be added to the event handler script called service_restart. Try editing like the example below and see if that works for you.
Code: Select all
define command { command_name service_restart command_line $USER1$/servicerestart.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$ $SERVICEDOWNTIME$
Re: Would event-handler get disabled with scheduled downtime
Ticket received, we'll pick up there. Going to close this thread in the meantime.
Former Nagios employee