event handler won't trigger
Posted: Fri Mar 15, 2019 10:32 am
hi everyone, I'm new to this forum, but I really need help.
I'm using CGI's and Mysql database to store information about health of my servers and reboot some of them if necessary, I'm trying to use the event handler from nagios to trigger a script that will make somme changes in database via CGI .
but the event_handler never trigger.
this is the services.cfg config:
define service{
name generic-service
active_checks_enabled 1 ; Active service checks enabled
passive_checks_enabled 1 ; Passive service checks enabled/accepted
parallelize_check 1 ; Active service checks parallelized
obsess_over_service 1 ; We should obsess over this service
check_freshness 0 ; Default is to NOT check service freshness
notifications_enabled 1 ; Service notifications enabled
event_handler_enabled 1 ; Service event handler enabled
flap_detection_enabled 1 ; Flap detection enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across restarts
retain_nonstatus_information 1 ; Retain non-status information across restarts
register 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups ****************
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
is_volatile 0
the service :
define service {
host_name mail2
use ping-service
event_handler notify_critical_bdd
register 1
}
the commands.cfg:
define command {
command_name notify_critical_bdd
command_line /usr/bin/notify_critical_bdd $HOSTNAME$ $HOSTADDRESS$ $SERVICEDESC$ $SERVICESTATE$
}
and nagios.cfg event_handler config:
log_event_handlers=1
event_handler_timeout=30
enable_event_handlers=1
the event_handler scipt (modified to trigger for any service state changes):
#!/bin/sh
sudo touch /tmp/test.log
sudo echo "$1 $2 $3 $4" >/tmp/test.log
today=`date`
case "$4" in
WARNING)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
OK)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
UNKNOWN)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
CRITICAL)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
*)
exit 0
;;
esac
exit 0
and every script and files used are for nagios user and are "chmod 777" and nagios is in the sudoers list.
cannot find why it doesn't work
Help please
))))
I'm using CGI's and Mysql database to store information about health of my servers and reboot some of them if necessary, I'm trying to use the event handler from nagios to trigger a script that will make somme changes in database via CGI .
but the event_handler never trigger.
this is the services.cfg config:
define service{
name generic-service
active_checks_enabled 1 ; Active service checks enabled
passive_checks_enabled 1 ; Passive service checks enabled/accepted
parallelize_check 1 ; Active service checks parallelized
obsess_over_service 1 ; We should obsess over this service
check_freshness 0 ; Default is to NOT check service freshness
notifications_enabled 1 ; Service notifications enabled
event_handler_enabled 1 ; Service event handler enabled
flap_detection_enabled 1 ; Flap detection enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across restarts
retain_nonstatus_information 1 ; Retain non-status information across restarts
register 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups ****************
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
is_volatile 0
the service :
define service {
host_name mail2
use ping-service
event_handler notify_critical_bdd
register 1
}
the commands.cfg:
define command {
command_name notify_critical_bdd
command_line /usr/bin/notify_critical_bdd $HOSTNAME$ $HOSTADDRESS$ $SERVICEDESC$ $SERVICESTATE$
}
and nagios.cfg event_handler config:
log_event_handlers=1
event_handler_timeout=30
enable_event_handlers=1
the event_handler scipt (modified to trigger for any service state changes):
#!/bin/sh
sudo touch /tmp/test.log
sudo echo "$1 $2 $3 $4" >/tmp/test.log
today=`date`
case "$4" in
WARNING)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
OK)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
UNKNOWN)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
CRITICAL)
sudo echo "$today $1 $2 $3 $4" >> /tmp/critical_log
;;
*)
exit 0
;;
esac
exit 0
and every script and files used are for nagios user and are "chmod 777" and nagios is in the sudoers list.
cannot find why it doesn't work
Help please