]> granicus.if.org Git - icinga2/blobdiff - lib/icinga/checkable.cpp
Merge pull request #6577 from Icinga/fix/setup-api-including-users-file
[icinga2] / lib / icinga / checkable.cpp
index fe2fed9e31330b32ad8ab0ff81f353bb05c040bb..c577848d59ed34ba93e08ec7be6e5d5f40a7f24b 100644 (file)
@@ -57,14 +57,16 @@ void Checkable::OnAllConfigLoaded()
        if (endpoint) {
                Zone::Ptr checkableZone = static_pointer_cast<Zone>(GetZone());
 
-               if (!checkableZone)
-                       checkableZone = Zone::GetLocalZone();
-
-               Zone::Ptr cmdZone = endpoint->GetZone();
-
-               if (checkableZone && cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
+               if (checkableZone) {
+                       Zone::Ptr cmdZone = endpoint->GetZone();
+
+                       if (cmdZone != checkableZone && cmdZone->GetParent() != checkableZone) {
+                               BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
+                                       "Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
+                       }
+               } else {
                        BOOST_THROW_EXCEPTION(ValidationError(this, { "command_endpoint" },
-                               "Command endpoint must be in zone '" + checkableZone->GetName() + "' or in a direct child zone thereof."));
+                               "Command endpoint must not be set."));
                }
        }
 }
@@ -198,6 +200,14 @@ void Checkable::ValidateCheckInterval(const Lazy<double>& lvalue, const Validati
                BOOST_THROW_EXCEPTION(ValidationError(this, { "check_interval" }, "Interval must be greater than 0."));
 }
 
+void Checkable::ValidateRetryInterval(const Lazy<double>& lvalue, const ValidationUtils& utils)
+{
+       ObjectImpl<Checkable>::ValidateRetryInterval(lvalue, utils);
+
+       if (lvalue() <= 0)
+               BOOST_THROW_EXCEPTION(ValidationError(this, { "retry_interval" }, "Interval must be greater than 0."));
+}
+
 void Checkable::ValidateMaxCheckAttempts(const Lazy<int>& lvalue, const ValidationUtils& utils)
 {
        ObjectImpl<Checkable>::ValidateMaxCheckAttempts(lvalue, utils);