From 0c2215a9f84bacd112c621d9c8b54f00ff79a207 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 19 May 2025 14:07:33 +0200 Subject: [PATCH] Checkable: Use correct timeout for rescheduling remote checks Previously, the `command#timeout` which by default is `1m`, was used to reschedule the just sent remote check. However, this results into a bunch of extra checks being sent to the remote host, even though the first one is still running. That's because if one want to override the default timeout of the command for a specific host/service, one has to set the `checkable#check_timeout` attribute to the desired value. So, this commit makes sure that the `checkable#check_timeout` attribute (if set) is used to reschedule the remote check. --- lib/icinga/checkable-check.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 2e96df5af..fdd3914c7 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -624,12 +624,16 @@ void Checkable::ExecuteCheck() if (service) params->Set("service", service->GetShortName()); + double checkTimeout = GetCheckCommand()->GetTimeout(); + /* * If the host/service object specifies the 'check_timeout' attribute, * forward this to the remote endpoint to limit the command execution time. */ - if (!GetCheckTimeout().IsEmpty()) - params->Set("check_timeout", GetCheckTimeout()); + if (auto ckCheckTimeout(GetCheckTimeout()); !ckCheckTimeout.IsEmpty()) { + checkTimeout = Convert::ToDouble(ckCheckTimeout); + params->Set("check_timeout", ckCheckTimeout); + } params->Set("macros", macros); @@ -642,7 +646,7 @@ void Checkable::ExecuteCheck() * a check result from the remote instance. The check will be re-scheduled * using the proper check interval once we've received a check result. */ - SetNextCheck(Utility::GetTime() + GetCheckCommand()->GetTimeout() + 30); + SetNextCheck(Utility::GetTime() + checkTimeout + 30); /* * Let the user know that there was a problem with the check if