Skip to content

Commit 0c2215a

Browse files
committed
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.
1 parent 8a1d9df commit 0c2215a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/icinga/checkable-check.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,16 @@ void Checkable::ExecuteCheck()
624624
if (service)
625625
params->Set("service", service->GetShortName());
626626

627+
double checkTimeout = GetCheckCommand()->GetTimeout();
628+
627629
/*
628630
* If the host/service object specifies the 'check_timeout' attribute,
629631
* forward this to the remote endpoint to limit the command execution time.
630632
*/
631-
if (!GetCheckTimeout().IsEmpty())
632-
params->Set("check_timeout", GetCheckTimeout());
633+
if (auto ckCheckTimeout(GetCheckTimeout()); !ckCheckTimeout.IsEmpty()) {
634+
checkTimeout = Convert::ToDouble(ckCheckTimeout);
635+
params->Set("check_timeout", ckCheckTimeout);
636+
}
633637

634638
params->Set("macros", macros);
635639

@@ -642,7 +646,7 @@ void Checkable::ExecuteCheck()
642646
* a check result from the remote instance. The check will be re-scheduled
643647
* using the proper check interval once we've received a check result.
644648
*/
645-
SetNextCheck(Utility::GetTime() + GetCheckCommand()->GetTimeout() + 30);
649+
SetNextCheck(Utility::GetTime() + checkTimeout + 30);
646650

647651
/*
648652
* Let the user know that there was a problem with the check if

0 commit comments

Comments
 (0)