]> granicus.if.org Git - icinga2/blobdiff - lib/icinga/checkable.cpp
Fix notify flag is ignored in ACKNOWLEDGE_*_PROBLEM commands
[icinga2] / lib / icinga / checkable.cpp
index e6a475351cdd2090b226788171cbd706d777e0f1..d54aa8ec514b8b434cb37760438b014f70f1afae 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  * Icinga 2                                                                   *
- * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)    *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org)    *
  *                                                                            *
  * This program is free software; you can redistribute it and/or              *
  * modify it under the terms of the GNU General Public License                *
  ******************************************************************************/
 
 #include "icinga/checkable.hpp"
-#include "config/configcompilercontext.hpp"
 #include "base/objectlock.hpp"
 #include "base/utility.hpp"
-#include "base/scriptfunction.hpp"
+#include "base/function.hpp"
+#include "base/exception.hpp"
 #include <boost/foreach.hpp>
 #include <boost/bind/apply.hpp>
 
@@ -31,7 +31,7 @@ REGISTER_TYPE(Checkable);
 REGISTER_SCRIPTFUNCTION(ValidateCheckableCheckInterval, &Checkable::ValidateCheckInterval);
 
 boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePerfdataChanged;
-boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet;
+boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet;
 boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> Checkable::OnAcknowledgementCleared;
 
 Checkable::Checkable(void)
@@ -121,7 +121,7 @@ bool Checkable::IsAcknowledged(void)
        return GetAcknowledgement() != AcknowledgementNone;
 }
 
-void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry, const MessageOrigin& origin)
+void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, double expiry, const MessageOrigin& origin)
 {
        {
                ObjectLock olock(this);
@@ -130,9 +130,10 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
                SetAcknowledgementExpiry(expiry);
        }
 
-       OnNotificationsRequested(this, NotificationAcknowledgement, GetLastCheckResult(), author, comment);
+       if (notify)
+               OnNotificationsRequested(this, NotificationAcknowledgement, GetLastCheckResult(), author, comment);
 
-       OnAcknowledgementSet(this, author, comment, type, expiry, origin);
+       OnAcknowledgementSet(this, author, comment, type, notify, expiry, origin);
 }
 
 void Checkable::ClearAcknowledgement(const MessageOrigin& origin)
@@ -271,6 +272,6 @@ void Checkable::ValidateCheckInterval(const String& location, const Checkable::P
 {
        if (object->GetCheckInterval() <= 0) {
                BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
-                   location + ": check_interval must be greater than 0.", GetDebugInfo()));
+                   location + ": check_interval must be greater than 0.", object->GetDebugInfo()));
        }
 }