]> granicus.if.org Git - icinga2/commitdiff
Implement support for overriding check command timeout
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 7 Apr 2016 13:07:17 +0000 (15:07 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 7 Apr 2016 13:07:17 +0000 (15:07 +0200)
fixes #9283

doc/6-object-types.md
lib/icinga/checkable.ti
lib/icinga/pluginutility.cpp

index 76cceb97d2fcbf2c5c78e331f765932d01cbfb5d..03e2c27d57602613aa8f86f83629f8fb837d0bf7 100644 (file)
@@ -563,6 +563,7 @@ Configuration Attributes:
   check\_command  |**Required.** The name of the check command.
   max\_check\_attempts|**Optional.** The number of times a host is re-checked before changing into a hard state. Defaults to 3.
   check\_period   |**Optional.** The name of a time period which determines when this host should be checked. Not set by default.
+  check\_timeout  |**Optional.** Check command timeout in seconds. Overrides the CheckCommand's `timeout` attribute.
   check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the host is in a `HARD` state. Defaults to 5 minutes.
   retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the host is in a `SOFT` state. Defaults to 1 minute.
   enable\_notifications|**Optional.** Whether notifications are enabled. Defaults to true.
@@ -1158,6 +1159,7 @@ Configuration Attributes:
   check\_command  |**Required.** The name of the check command.
   max\_check\_attempts|**Optional.** The number of times a service is re-checked before changing into a hard state. Defaults to 3.
   check\_period   |**Optional.** The name of a time period which determines when this service should be checked. Not set by default.
+  check\_timeout  |**Optional.** Check command timeout in seconds. Overrides the CheckCommand's `timeout` attribute.
   check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the service is in a `HARD` state. Defaults to 5 minutes.
   retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1 minute.
   enable\_notifications|**Optional.** Whether notifications are enabled. Defaults to true.
index d94aeb5f7e789141daadbd052387bd4c0c229a60..f3621e8f70a6a23a176b27d7189bb41bcdf99d7f 100644 (file)
@@ -57,6 +57,7 @@ abstract class Checkable : CustomVarObject
                        return TimePeriod::GetByName(GetCheckPeriodRaw());
                }}}
        };
+       [config] Value check_timeout;
        [config] double check_interval {
                default {{{ return 5 * 60; }}}
        };
index 803b9e7a0f57409ef002a6b6fb8c82e5b972b229..bdc4a74bbf477e92bce74894fdf0058c40b1dc41 100644 (file)
@@ -88,7 +88,12 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
                return;
 
        Process::Ptr process = new Process(Process::PrepareCommand(command), envMacros);
-       process->SetTimeout(commandObj->GetTimeout());
+
+       if (checkable->GetCheckTimeout().IsEmpty())
+               process->SetTimeout(commandObj->GetTimeout());
+       else
+               process->SetTimeout(checkable->GetCheckTimeout());
+
        process->Run(boost::bind(callback, command, _1));
 }