Setting a timeout for a custom script
Posted: Thu Aug 05, 2021 4:37 am
Hello,
for the company I work for, I created a bash script that works as a Nagios plugins.
Without entering too much into details, this script using curl, calls an API and downloads a json with an undefined number of "events" since last 12 hours.
The script, due to the API limitation, can download up to 10.000 events at a time.
If the events since last 12 hours are less than 10.000 the scripts runs one time only. If the events are more than 10.000, the scripts runs recursively and downloads 10k events until the events are all downloaded.
Now, on Nagios the global timeout for plugins is 61 seconds. I calculated that if I have 180k events (in worst case scenario) to downloads, it will require the script to run 18 times. 61/18=3.38. 3.38 seconds is the max time that the single iteration of the script can take to get 10k events.
The problem is: due to some network slowness, I'm afraid that the script couldn't finish to download all the events within the 61 seconds timeout.
Hence the question: can I tell Nagios to increase the timeout only for my plugin and leave the 61 secs for all the others?
Side note: when the timeout kicks-in, Nagios kils the script and leaves the json file = bad. When the script runs again after x minutes, it finds the json file already present and thinks that the previous script is still running.
for the company I work for, I created a bash script that works as a Nagios plugins.
Without entering too much into details, this script using curl, calls an API and downloads a json with an undefined number of "events" since last 12 hours.
The script, due to the API limitation, can download up to 10.000 events at a time.
If the events since last 12 hours are less than 10.000 the scripts runs one time only. If the events are more than 10.000, the scripts runs recursively and downloads 10k events until the events are all downloaded.
Now, on Nagios the global timeout for plugins is 61 seconds. I calculated that if I have 180k events (in worst case scenario) to downloads, it will require the script to run 18 times. 61/18=3.38. 3.38 seconds is the max time that the single iteration of the script can take to get 10k events.
The problem is: due to some network slowness, I'm afraid that the script couldn't finish to download all the events within the 61 seconds timeout.
Hence the question: can I tell Nagios to increase the timeout only for my plugin and leave the 61 secs for all the others?
Side note: when the timeout kicks-in, Nagios kils the script and leaves the json file = bad. When the script runs again after x minutes, it finds the json file already present and thinks that the previous script is still running.