Page 1 of 1

Event_handler - OK Status Problema

Posted: Mon Sep 14, 2020 2:12 pm
by paulo.ferreira
i'm trying to create a event_handler to open and close a ticket automatically in an internal ticket system.
But my event works well if the service status change of OK to critical or warning, but otherway don't, so that way I'm not able to close the ticket automatically.

Any guess ?

PS: I follow the instructions below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: Event_handler - OK Status Problema

Posted: Mon Sep 14, 2020 2:25 pm
by scottwilkerson
Can you show the event_handler_ticket.sh you created?

Did you add an elif block on what to do if the $SERVICESTATE is OK?

Re: Event_handler - OK Status Problema

Posted: Tue Sep 15, 2020 10:05 am
by paulo.ferreira

Code: Select all

#!/bin/bash
#Script nagios - top

#Variaveis

DATE=$(date)
title="${3} - ${4} - Nagios Alert ${1}"
desc="${DATE} - ${3}- ${8} - ${7}"

case "$1" in
OK)

/opt/mssql-tools/bin/sqlcmd -S 1.1.1.1 -U nagios -P password -Q "exec sp_event_bus @object = '$3',@code = 'MONC',@event_key = '',@summary = '$title',@descripti
on = '$desc',@has_clear_event = 1,@is_clear_event = 1" | tee -a /tmp/log.txt
;;
WARNING)
#chamados warning

/opt/mssql-tools/bin/sqlcmd -S 1.1.1.1 -U nagios -P password -Q "exec sp_event_bus @object = '$3',@code = 'MONW',@event_key = '',@summary = '$title',@descripti
on = '$desc',@has_clear_event = 1,@is_clear_event = 0" | tee -a /tmp/log.txt
;;
UNKNOWN)
;;
CRITICAL)

#chamados critical

/opt/mssql-tools/bin/sqlcmd -S 1.1.1.1 -U nagios -P password -Q "exec sp_event_bus @object = '$3',@code = 'MONC',@event_key = '',@summary = '$title',@descripti
on = '$desc',@has_clear_event = 1,@is_clear_event = 0" | tee -a /tmp/log.txt
;;
esac
exit 0
If SERVICESTATE is WARNING or CRITICAL, the event_handler is called and execute the script, but it seems that the event_handler is not called when the SERVICESTATE go to OK status.

If we call the script mannualy informing the SERVICESTATE status, the script works. The question is why the event_handler script is not called when the status changed from CRITICAL to OK?

Re: Event_handler - OK Status Problema

Posted: Tue Sep 15, 2020 12:29 pm
by scottwilkerson
Are you adding this to an individual service, or as a global event handler?

They should be kicked off on recovery
https://assets.nagios.com/downloads/nag ... dlers.html
When Are Event Handlers Executed?

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

SOFT and HARD states are described in detail here .
What version of Nagios XI are you running?

Re: Event_handler - OK Status Problema

Posted: Tue Sep 15, 2020 1:23 pm
by paulo.ferreira
Individual Services.
Nagios XI 5.8

Re: Event_handler - OK Status Problema

Posted: Tue Sep 15, 2020 4:07 pm
by scottwilkerson
paulo.ferreira wrote:Individual Services.
Nagios XI 5.8
Nagios XI 5.8 has not been released yet, can you re-check the version?

Re: Event_handler - OK Status Problema

Posted: Wed Sep 16, 2020 1:53 pm
by paulo.ferreira
Sorry, mb.

5.5.8

Re: Event_handler - OK Status Problem

Posted: Wed Sep 16, 2020 2:02 pm
by paulo.ferreira
Actually, when we were trying to test the event handler, and we were using a test script call event_handler_ping.sh, but we don't no why, when the service status change, runs our prior event_handler which the name is event_handler.sh, although our configuration at service panel.

Any guess, where maybe i acidentally setup a global event handler ?

Re: Event_handler - OK Status Problema

Posted: Wed Sep 16, 2020 3:31 pm
by scottwilkerson
Can you PM me a profile.zip from Admin -> System profile

Also, please include the name of the host & service this is assigned to