Page 1 of 1

Python time.sleep() doesn't work in command_line

Posted: Mon Jul 08, 2013 3:17 pm
by Thaxll
Hello,

I'm facing a weird problem, I've got a simple:

define command {
command_name notify-service-by-email
command_line /opt/test.py --message "$SERVICEOUTPUT$"
}

The test.py contains a loop with a time.sleep(300) between elements, the first element of the loop is executed and then the program is exited. It's strange because it should loop over all items before quiting, When I run manualy the Python script everything is fine.
Is there a timeout or something within 'command_line' preventing the time.sleep() to be executed?

Thank you,

Re: Python time.sleep() doesn't work in command_line

Posted: Mon Jul 08, 2013 3:22 pm
by abrist
You can adjust the maximum timeout value for service checks by using the service_check_timeout directive in the main configuration file.
From: http://nagios.sourceforge.net/docs/3_0/configmain.html
Format: service_check_timeout=<seconds>
Example: service_check_timeout=60

This is the maximum number of seconds that Nagios will allow service checks to run. If checks exceed this limit, they are killed and a CRITICAL state is returned. A timeout error will also be logged.

There is often widespread confusion as to what this option really does. It is meant to be used as a last ditch mechanism to kill off plugins which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each service check normally finishes executing within this time limit. If a service check runs longer than this limit, Nagios will kill it off thinking it is a runaway processes.

Re: Python time.sleep() doesn't work in command_line

Posted: Mon Jul 08, 2013 4:00 pm
by Thaxll
Thank you very much, increasing one of that value fixed the problem :)