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

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
Thaxll
Posts: 2
Joined: Mon Jul 08, 2013 3:10 pm

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

Post 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,
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Thaxll
Posts: 2
Joined: Mon Jul 08, 2013 3:10 pm

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

Post by Thaxll »

Thank you very much, increasing one of that value fixed the problem :)
Locked