Closed enidvx closed 9 months ago
I did this modification to the script in order to "fix" this. Actually it does what I am expecting it to do, adding a timeout and throwing an exception when that timeout is exceeded.
diff --git a/check_spring_actuator.py b/check_spring_actuator.py
index 9122f4602..f0e2de592 100755
--- a/check_spring_actuator.py
+++ b/check_spring_actuator.py
@@ -8,7 +8,7 @@ import logging
from pynag.Plugins import PluginHelper, ok, critical, unknown
from requests import get
-from requests.exceptions import ConnectionError
+from requests.exceptions import ConnectionError, Timeout
helper = PluginHelper()
@@ -52,7 +52,7 @@ def request_data(url, **get_args):
"""executes get request to retrieve data from given url"""
logging.captureWarnings(True)
try:
- response = get(url, **get_args)
+ response = get(url, **get_args, timeout=60) # set default timeout as Icinga checks
if response.ok or response.status_code == 503:
return response.json(), Exception(response.status_code, url)
else:
@@ -60,6 +60,9 @@ def request_data(url, **get_args):
except ConnectionError as e:
helper.debug('error fetching data from {}'.format(url))
return None, e
+ except Timeout as t:
+ helper.debug('timeout fetching data from {}'.format(url))
+ return None, t
finally:
logging.captureWarnings(False)
Please check if this makes sense to you. Thanks. Enid
Hi, I am getting these output from the script
Unknown - Plugin timeout exceeded after 58 seconds.
But the status is Green andOK
The timeout doesn't come from the Icinga settings and is not Terminated by it (it is set to 3minutes actually)
Is there any way to output the correct status
Unknown
and notOK
for this case?Thank you, Enid