Problem with enabling event handlers for restarting service

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mzakk
Posts: 5
Joined: Thu Sep 01, 2016 4:19 am

Problem with enabling event handlers for restarting service

Post by mzakk »

Hello,

I installed Nagios, and I would like to use the event handler to restart a failed service, although I am finding this difficutl to make the event handler working. The event handler is not executing the script I want. Could anybody help me and tell me what is wrong with my set up? I will really appreciate for help.

Firstly I would like to restart local application (installed on the same server as Nagios). Below are the files i modified:

1. Enabled event_handlers

/usr/local/nagios/etc/nagios.cfg

enable_event_handlers=1

2. Modified the command.cfg file and added the the following commands

/usr/local/nagios/etc/objects/commands.cfg

define command{
command_name check_http_procs
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
define command {
command_name restart-services
command_line /usr/local/nagios/libexec/eventhandlers/restart-services.sh
}

3. Modified the localhost.cfg file and added the folloiwing service

/usr/local/nagios/etc/objects/localhost.cfg

define service {
use local-service
host_name localhost
service_description Check Application if not running restart
max_check_attempts 3
event_handler_enabled 1
retry_check_interval 1
check_command check_http_procs!-H localhost -p 8080 -u /application.jsp
event_handler restart-services
}

4. I created the following scripts (founded on stackoverflow) just for testing as my original restart script was not executed as well, so for debuging

/usr/local/nagios/libexec/eventhandlers directory I created restart-services.sh script

#!/bin/bash
exec 2> /tmp/log."$$"
set -x
wall "Script execution started";
/usr/bin/sudo /root/scripts/disableServer.sh

the disableServer.sh script looks as follow
#!/bin/bash
echo "Test"

I allowed nagios user to run the script in the following way:
Defaults:nagios !requiretty,visiblepw
Cmnd_Alias NAGIOS_START_APP = /sbin/service, /bin/bash, /root/scripts/disableServer.sh
nagios ALL=(ALL) NOPASSWD: NAGIOS_STARt_APP


I can stop my custom application and the Nagios is reporting correctly that the application is not responding, although the event handler is not executing my custom script that I would like to use for restartin.

Could anybody tell me what I am doing wrong or post me some setup I could use for debuging the event handlers?


Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Problem with enabling event handlers for restarting serv

Post by rkennedy »

At a quick glance, your configuration looks fine. Could you manually test running /usr/local/nagios/libexec/eventhandlers/restart-services.sh and /root/scripts/disableServer.sh as the nagios user? This should help to make sure they are working properly.

Code: Select all

su nagios
/usr/local/nagios/libexec/eventhandlers/restart-services.sh
/root/scripts/disableServer.sh
Also, the echo isn't going to be visible either way, so I'm unsure how you're confirming it works or not. You may want to pipe it into a file to test with.

Code: Select all

#!/bin/bash
echo "Test" >> /tmp/testeventhandlers.txt
Former Nagios Employee
mzakk
Posts: 5
Joined: Thu Sep 01, 2016 4:19 am

Re: Problem with enabling event handlers for restarting serv

Post by mzakk »

Thanks for the reply,

The problem I have is that the event_handler command is doing nothing
#!/bin/bash
echo "Test" >> /tmp/testeventhandlers.txt

I can stop the application the Nagios check command is detecting that the applicatios is down, but Nagios is not executing the event handler command, I only would like to get the simple test message writen into file.

Do I am missing something else from my set up?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Problem with enabling event handlers for restarting serv

Post by rkennedy »

Exactly, the echo you posted has no way of validating it is actually running, which is why I noted to output to that file. Did you adjust the script as I suggested to pipe it to the file?

As I mentioned, please run through the commands I posted over the CLI as the nagios user to make sure it's working properly. It is most likely a permission problem if something is failing and this will help to see where.
Former Nagios Employee
mzakk
Posts: 5
Joined: Thu Sep 01, 2016 4:19 am

Re: Problem with enabling event handlers for restarting serv

Post by mzakk »

Hi, Thanks again for the response I did the script as you suggested and the scripts are executable by nagios when doing:
su nagios
/usr/local/nagios/libexec/eventhandlers/restart-services.sh
/root/scripts/disableServer.sh

The response is written to the file as expected. The problem is that Nagios is not doing anything and not executing the event handler command even in the nagios.log there is nothing suggested that the event handler is executing or whatever. Are there any other debuging options available for event handler?
mzakk
Posts: 5
Joined: Thu Sep 01, 2016 4:19 am

Re: Problem with enabling event handlers for restarting serv

Post by mzakk »

Does anybody have any ideas how can I debug the event handler command in Nagios?
Below is the output from Nagios logs. Nagios is reporting correctly whe the application is running and is reporting correctly when the applications is stopping, although is not doing anything on on event handler command, how can I force nagios to execute the event handler?

HTTP OK: HTTP/1.1 200 OK - 45349 bytes in 3.173 second response time |time=3.172706s;;;0.000000 size=45349B;;;0
HTTP OK: HTTP/1.1 200 OK - 44836 bytes in 0.156 second response time |time=0.155545s;;;0.000000 size=44836B;;;0
connect to address localhost and port 8080: Connection refused
HTTP CRITICAL - Unable to open TCP socket
connect to address localhost and port 8080: Connection refused
HTTP CRITICAL - Unable to open TCP socket
connect to address localhost and port 8080: Connection refused
HTTP CRITICAL - Unable to open TCP socket
connect to address localhost and port 8080: Connection refused
HTTP CRITICAL - Unable to open TCP socket
connect to address localhost and port 8080: Connection refused
HTTP CRITICAL - Unable to open TCP socket
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Problem with enabling event handlers for restarting serv

Post by rkennedy »

Please post your /usr/local/nagios/var/objects.cache for us to look at, as this will show us how Nagios has compiled all of your configuration files.
Former Nagios Employee
mzakk
Posts: 5
Joined: Thu Sep 01, 2016 4:19 am

Re: Problem with enabling event handlers for restarting serv

Post by mzakk »

Thanks for the reply, this is how /usr/local/nagios/var/objects.cache looks:

Code: Select all

########################################
#       NAGIOS OBJECT CACHE FILE
#
# THIS FILE IS AUTOMATICALLY GENERATED
# BY NAGIOS.  DO NOT MODIFY THIS FILE!
#
# Created: Fri Sep  2 10:23:04 2016
########################################

define timeperiod {
	timeperiod_name	24x7
	alias	24 Hours A Day, 7 Days A Week
	sunday	00:00-24:00
	monday	00:00-24:00
	tuesday	00:00-24:00
	wednesday	00:00-24:00
	thursday	00:00-24:00
	friday	00:00-24:00
	saturday	00:00-24:00
	}

define timeperiod {
	timeperiod_name	24x7_sans_holidays
	alias	24x7 Sans Holidays
	december 25	00:00-00:00
	july 4	00:00-00:00
	january 1	00:00-00:00
	thursday 4 november	00:00-00:00
	monday 1 september	00:00-00:00
	monday -1 may	00:00-00:00
	sunday	00:00-24:00
	monday	00:00-24:00
	tuesday	00:00-24:00
	wednesday	00:00-24:00
	thursday	00:00-24:00
	friday	00:00-24:00
	saturday	00:00-24:00
	}

define timeperiod {
	timeperiod_name	none
	alias	No Time Is A Good Time
	}

define timeperiod {
	timeperiod_name	us-holidays
	alias	U.S. Holidays
	january 1	00:00-00:00
	july 4	00:00-00:00
	december 25	00:00-00:00
	monday -1 may	00:00-00:00
	monday 1 september	00:00-00:00
	thursday 4 november	00:00-00:00
	}

define timeperiod {
	timeperiod_name	workhours
	alias	Normal Work Hours
	monday	09:00-17:00
	tuesday	09:00-17:00
	wednesday	09:00-17:00
	thursday	09:00-17:00
	friday	09:00-17:00
	}

define command {
	command_name	check-host-alive
	command_line	$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
	}

define command {
	command_name	check_dhcp
	command_line	$USER1$/check_dhcp $ARG1$
	}

define command {
	command_name	check_ftp
	command_line	$USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_hpjd
	command_line	$USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_http
	command_line	$USER1$/check_http -I $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_imap
	command_line	$USER1$/check_imap -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name check_http_procs
    command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
	}

define command {
	command_name	check_local_disk
	command_line	$USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
	}

define command {
	command_name	check_local_load
	command_line	$USER1$/check_load -w $ARG1$ -c $ARG2$
	}

define command {
	command_name	check_local_mrtgtraf
	command_line	$USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
	}

define command {
	command_name	check_local_procs
	command_line	$USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
	}

define command {
	command_name	check_local_swap
	command_line	$USER1$/check_swap -w $ARG1$ -c $ARG2$
	}

define command {
	command_name	check_local_users
	command_line	$USER1$/check_users -w $ARG1$ -c $ARG2$
	}

define command {
	command_name	check_nt
	command_line	$USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
	}

define command {
	command_name	check_ping
	command_line	$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
	}

define command {
	command_name	check_pop
	command_line	$USER1$/check_pop -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_rest
	command_line	$USER1$/check_rest $ARG1$ $ARG2$ $ARG3$ $ARG4$
	}

define command {
	command_name	check_smtp
	command_line	$USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_snmp
	command_line	$USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
	}

define command {
	command_name	check_ssh
	command_line	$USER1$/check_ssh $ARG1$ $HOSTADDRESS$
	}

define command {
	command_name	check_tcp
	command_line	$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
	}

define command {
	command_name	check_udp
	command_line	$USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
	}

define command {
	command_name	 restart-services
	command_line	/usr/local/nagios/libexec/eventhandlers/restart-services.sh $SERVICEDESC$ $SERVICESTATE$ $SERVICESTATETYPE$
	}

define command {
	command_name	notify-host-by-email
	command_line	/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
	}

define command {
	command_name	notify-service-by-email
	command_line	/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
	}

define command {
	command_name	nscd-restart
	command_line	$USER1$/eventhandlers/nscd-restart $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$
	}

define command {
	command_name	nscd-restart-esh
	command_line	$USER1$/eventhandlers/nscd-restart-esh
	}

define command {
	command_name	process-host-perfdata
	command_line	/usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
	}

define command {
	command_name	process-service-perfdata
	command_line	/usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
	}

define command {
	command_name	restart-nscd
	command_line	$USER8$/restart-nscd.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$
	}

define command {
	command_name	restart-services
	command_line	/usr/local/nagios/libexec/eventhandlers/restart-services.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
	}

define command {
	command_name	test-command
	command_line	/usr/local/nagios/libexec/eventhandlers/event_handler_test.sh
	}

define command {
	command_name	usedspace_bash
	command_line	$USER1$/custom-check-usage -H $HOSTADDRESS$ -c usedspace_bash
	}

define contactgroup {
	contactgroup_name	admins
	alias	Nagios Administrators
	members	nagiosadmin
	}

define hostgroup {
	hostgroup_name	linux-servers
	alias	Linux Servers
	members	localhost
	}

define contact {
	contact_name	nagiosadmin
	alias	Nagios Admin
	service_notification_period	24x7
	host_notification_period	24x7
	service_notification_options	r,w,u,c,f,s
	host_notification_options	r,d,u,f,s
	service_notification_commands	notify-service-by-email
	host_notification_commands	notify-host-by-email
	email	nagios@localhost
	minimum_importance	0
	host_notifications_enabled	1
	service_notifications_enabled	1
	can_submit_commands	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define host {
	host_name	localhost
	alias	localhost
	address	127.0.0.1
	check_period	24x7
	check_command	check-host-alive
	event_handler	restart-services
	contact_groups	admins
	notification_period	workhours
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	10
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,d,u
	notifications_enabled	1
	notification_interval	120.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Check Application if not running restart
	check_period	24x7
	check_command check_http_procs!-H localhost -p 8080 -u /application.jsp
	event_handler	 restart-services
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	10.000000
	retry_interval	3.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Current Load
	check_period	24x7
	check_command	check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Current Users
	check_period	24x7
	check_command	check_local_users!20!50
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Custom Disk Checker In Bash
	check_period	24x7
	check_command	usedspace_bash
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	10.000000
	retry_interval	2.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Custom NSCD
	check_period	24x7
	check_command	nscd-restart!0:!1 -C nscd
	event_handler	nscd-restart
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	10.000000
	retry_interval	2.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	HTTP
	check_period	24x7
	check_command	check_http
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	0
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	NSCD Check start if stopped
	check_period	24x7
	check_command	nscd-restart-esh
	event_handler	restart-nscd
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	10.000000
	retry_interval	2.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	0
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	PING
	check_period	24x7
	check_command	check_ping!100.0,20%!500.0,60%
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	REST service check
	check_period	24x7
	check_command	check_rest!$HOSTADDRESS$!7000!user!password
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	10.000000
	retry_interval	3.000000
	max_check_attempts	3
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Root Partition
	check_period	24x7
	check_command	check_local_disk!20%!10%!/
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	SSH
	check_period	24x7
	check_command	check_ssh
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	0
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Swap Usage
	check_period	24x7
	check_command	check_local_swap!20!10
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

define service {
	host_name	localhost
	service_description	Total Processes
	check_period	24x7
	check_command	check_local_procs!250!400!RSZDT
	contact_groups	admins
	notification_period	24x7
	initial_state	o
	importance	0
	check_interval	5.000000
	retry_interval	1.000000
	max_check_attempts	4
	is_volatile	0
	parallelize_check	1
	active_checks_enabled	1
	passive_checks_enabled	1
	obsess	1
	event_handler_enabled	1
	low_flap_threshold	0.000000
	high_flap_threshold	0.000000
	flap_detection_enabled	1
	flap_detection_options	a
	freshness_threshold	0
	check_freshness	0
	notification_options	r,w,u,c
	notifications_enabled	1
	notification_interval	60.000000
	first_notification_delay	0.000000
	stalking_options	n
	process_perf_data	1
	retain_status_information	1
	retain_nonstatus_information	1
	}

User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Problem with enabling event handlers for restarting serv

Post by tgriep »

I looked in the objects cache file and I see 2 commands called restart-services
One of them has a space in front of the name and the other doesn't.
Edit the commands.cfg file and fix the restart-services command and see if it works for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked