Nagios Version: 5.5.8
O.S: CentOS Linux release 7.5.1804 (Core)
Core/CPU: 2 Core / Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
Mem: 4Gb
######
Hi!
I have created an event handler (E.H), according to the documentation of Nagios (It is not the first time I do it), but in this opportunity I do not obtain any record of the execution of the E.H.
The E.H. I have configured it to execute a script in bash when the service falls in Warning and Critical states, this bash in turn executes a scrip php that sends an instruction (select), to a database.
The permissions of the files are in 775 and the owner is nagios.nagios
I have no records of errors in the nagios log, it is as if the command was not associated with the service.
Any ideas?
Service Event Handler is not executed or registered in the L
Re: Service Event Handler is not executed or registered in t
Well, our Nagios is integrated with Mod_Gearman and I discovered that the execution of Event Handlers was disabled as well as the E.H regitro in the nagios.log.
Now you can see in the record that the E.H. it is executed, but the script does not give the expected result ....
Now you can see in the record that the E.H. it is executed, but the script does not give the expected result ....
Re: Service Event Handler is not executed or registered in t
This is likely related to the event handler needing to be run on the XI server (instead of by the gearman worker).
Please attach your event handler command definition and the actual event handler script that you wrote so that we can see what it does exactly.
Thank you
Please attach your event handler command definition and the actual event handler script that you wrote so that we can see what it does exactly.
Thank you
Re: Service Event Handler is not executed or registered in t
Thanks, I attach the files
The file "ehhistorialalarmas.sh" detects the states and executes the php file "actualiza_alarma_historico.php" which makes an injection of data to MySQL
The file "ehhistorialalarmas.sh" detects the states and executes the php file "actualiza_alarma_historico.php" which makes an injection of data to MySQL
You do not have the required permissions to view the files attached to this post.
Re: Service Event Handler is not executed or registered in t
I assume those two files are located in /usr/local/nagios/etc/libexec, correct?
Please run these commands:
Then use this modified ehhistorialalarmas.sh script instead:
Let us know if that works for you.
Please run these commands:
Code: Select all
chown apache.nagios /usr/local/nagios/libexec/ehhistorialalarmas.sh
chown apache.nagios /usr/local/nagios/libexec/actualiza_alarma_historico.php
chmod 775 /usr/local/nagios/libexec/ehhistorialalarmas.sh
chmod 775 /usr/local/nagios/libexec/actualiza_alarma_historico.php
Code: Select all
#!/bin/bash
#
#
phpbin=$(which php)
cmdline="$phpbin -f /usr/local/nagios/libexec/actualiza_alarma_historico.php"
echo -e "\n $cmdline $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}" >> archivo.txt #only for logs
# Deteccion del estado de la alarma
case "$1" in
OK)
echo -e "\n Todo bien, no se genera alarma" >> archivo.txt #only for logs
;;
WARNING)
echo -e "\n Estado WARNING Hard..." >> archivo.txt #only for logs
$($cmdline "$4" "$5" "$6" "$7" "$8" "$9" "${10}")
;;
UNKNOWN)
echo "Estado desconocido, no genera alarma" >> archivo.txt #only for logs
;;
CRITICAL)
echo -e "\n Estado critical hard..." >> archivo.txt #only for logs
$($cmdline "$4" "$5" "$6" "$7" "$8" "$9" "${10}")
;;
esac
exit 0
Let us know if that works for you.
Re: Service Event Handler is not executed or registered in t
It is strange, the log indicates that the E.H has been executed, but I have no activity that confirms it.
The command and service files are the following
define command {
command_name EH_TrackitHistorialAlarmas
command_line $USER1$/ehhistorialalarmas.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $_SERVICEIDALARMA$ $LASTSERVICECHECK$ $LASTSERVICECHECK$ $_SERVICESERIAL$ $_SERVICEEVENTO$ $SERVICEOUTPUT$ $_SERVICESUCURSAL$
}
define service {
host_name xmartic.cloud
service_description Nodo 18 Control Suelos - Limite Maximo: Humedad - 1000043
use xiwizard_postgresquery_service
display_name Nodo 18
servicegroups Trackit Sensores
check_command check_postgres_query!rabbit_dba!nagios!N4g10s_01!select rb_medicion_data FROM sp_generaalarmav2(8,'Sensor de Humedad',1000043)!30!90!!
is_volatile 0
max_check_attempts 3
check_interval 1
retry_interval 1
active_checks_enabled 1
passive_checks_enabled 1
check_period xi_timeperiod_24x7
event_handler EH_TrackitHistorialAlarmas
event_handler_enabled 1
notification_interval 30
first_notification_delay 0
notification_period xi_timeperiod_24x7
notification_options w,c,
notifications_enabled 1
contact_groups Trackit Sensores Xmartic
notes Humedad
notes_url Humedad Nodo 18
_empresa Control Suelos
_evento Sensor de Humedad
_idalarma 60
_limcrit 110
_limprev 105
_serial 1000043
_sucursal Nodo 18
_xiwizard postgresquery
register 1
}
The service delivers user macross to the command
The command and service files are the following
define command {
command_name EH_TrackitHistorialAlarmas
command_line $USER1$/ehhistorialalarmas.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $_SERVICEIDALARMA$ $LASTSERVICECHECK$ $LASTSERVICECHECK$ $_SERVICESERIAL$ $_SERVICEEVENTO$ $SERVICEOUTPUT$ $_SERVICESUCURSAL$
}
define service {
host_name xmartic.cloud
service_description Nodo 18 Control Suelos - Limite Maximo: Humedad - 1000043
use xiwizard_postgresquery_service
display_name Nodo 18
servicegroups Trackit Sensores
check_command check_postgres_query!rabbit_dba!nagios!N4g10s_01!select rb_medicion_data FROM sp_generaalarmav2(8,'Sensor de Humedad',1000043)!30!90!!
is_volatile 0
max_check_attempts 3
check_interval 1
retry_interval 1
active_checks_enabled 1
passive_checks_enabled 1
check_period xi_timeperiod_24x7
event_handler EH_TrackitHistorialAlarmas
event_handler_enabled 1
notification_interval 30
first_notification_delay 0
notification_period xi_timeperiod_24x7
notification_options w,c,
notifications_enabled 1
contact_groups Trackit Sensores Xmartic
notes Humedad
notes_url Humedad Nodo 18
_empresa Control Suelos
_evento Sensor de Humedad
_idalarma 60
_limcrit 110
_limprev 105
_serial 1000043
_sucursal Nodo 18
_xiwizard postgresquery
register 1
}
The service delivers user macross to the command
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Service Event Handler is not executed or registered in t
If you want the event handlers to run on the local Nagios XI system and not on one of the mod_gearman workers, you need to first verify the config line in the nagios.cfg has eventhandler=no
such as:
Otherwise the event handler will be sent to one of your workers and the command for the event handler will try to execute there which likely doesn't have the plugin.
such as:
Code: Select all
broker_module=/usr/lib64/mod_gearman2/mod_gearman2.o config=/etc/mod_gearman2/module.conf eventhandler=no
Re: Service Event Handler is not executed or registered in t
Well, everything has been for a wrong configuration of Mod_Gearman and the Workers.
I have disabled the execution of Event Handlers in the workers and I have configured the Gearman server that does not distribute the event handlers and now everything works perfectly.
Thanks for the help and guidance, the problem is solved
I have disabled the execution of Event Handlers in the workers and I have configured the Gearman server that does not distribute the event handlers and now everything works perfectly.
Thanks for the help and guidance, the problem is solved
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Service Event Handler is not executed or registered in t
Great! Glad it is resolvedevisus wrote:Well, everything has been for a wrong configuration of Mod_Gearman and the Workers.
I have disabled the execution of Event Handlers in the workers and I have configured the Gearman server that does not distribute the event handlers and now everything works perfectly.
Thanks for the help and guidance, the problem is solved
Locking thread