void ApiEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
const String& author, const String& comment, AcknowledgementType type,
- double expiry, const MessageOrigin& origin)
+ bool notify, double expiry, const MessageOrigin& origin)
{
ApiListener::Ptr listener = ApiListener::GetInstance();
params->Set("author", author);
params->Set("comment", comment);
params->Set("acktype", type);
+ params->Set("notify", notify);
params->Set("expiry", expiry);
Dictionary::Ptr message = new Dictionary();
checkable->AcknowledgeProblem(params->Get("author"), params->Get("comment"),
static_cast<AcknowledgementType>(static_cast<int>(params->Get("acktype"))),
- params->Get("expiry"), origin);
+ params->Get("notify"), params->Get("expiry"), origin);
return Empty;
}
static void DowntimeRemovedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const MessageOrigin& origin);
static Value DowntimeRemovedAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
- static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, double expiry, const MessageOrigin& origin);
+ static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type,
+ bool notify, double expiry, const MessageOrigin& origin);
static Value AcknowledgementSetAPIHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin& origin);
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)
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);
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)
AcknowledgementType GetAcknowledgement(void);
- void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0, const MessageOrigin& origin = MessageOrigin());
+ void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, double expiry = 0, const MessageOrigin& origin = MessageOrigin());
void ClearAcknowledgement(const MessageOrigin& origin = MessageOrigin());
/* Checks */
static boost::signals2::signal<void (const Checkable::Ptr&, FlappingState)> OnFlappingChanged;
static boost::signals2::signal<void (const Checkable::Ptr&, const Downtime::Ptr&)> OnDowntimeTriggered;
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType,
- double, const MessageOrigin&)> OnAcknowledgementSet;
+ bool, double, const MessageOrigin&)> OnAcknowledgementSet;
static boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> OnAcknowledgementCleared;
static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted;
void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<String>& arguments)
{
bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false);
+ bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false);
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
Log(LogNotice, "ExternalCommandProcessor")
- << "Setting acknowledgement for service '" << service->GetName() << "'";
+ << "Setting acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
service->AddComment(CommentAcknowledgement, arguments[5], arguments[6], 0);
- service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal);
+ service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify);
}
void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::vector<String>& arguments)
{
bool sticky = (Convert::ToLong(arguments[2]) == 2 ? true : false);
+ bool notify = (Convert::ToLong(arguments[3]) > 0 ? true : false);
double timestamp = Convert::ToDouble(arguments[5]);
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
Log(LogNotice, "ExternalCommandProcessor")
- << "Setting timed acknowledgement for service '" << service->GetName() << "'";
+ << "Setting timed acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
service->AddComment(CommentAcknowledgement, arguments[6], arguments[7], 0);
- service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
+ service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, timestamp);
}
void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vector<String>& arguments)
void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector<String>& arguments)
{
bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
+ bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
Host::Ptr host = Host::GetByName(arguments[0]);
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem for non-existent host '" + arguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor")
- << "Setting acknowledgement for host '" << host->GetName() << "'";
+ << "Setting acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
if (host->GetState() == HostUp)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
host->AddComment(CommentAcknowledgement, arguments[4], arguments[5], 0);
- host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal);
+ host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify);
}
void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::vector<String>& arguments)
{
bool sticky = (Convert::ToLong(arguments[1]) == 2 ? true : false);
+ bool notify = (Convert::ToLong(arguments[2]) > 0 ? true : false);
double timestamp = Convert::ToDouble(arguments[4]);
Host::Ptr host = Host::GetByName(arguments[0]);
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem with expire time for non-existent host '" + arguments[0] + "'"));
Log(LogNotice, "ExternalCommandProcessor")
- << "Setting timed acknowledgement for host '" << host->GetName() << "'";
+ << "Setting timed acknowledgement for host '" << host->GetName() << "'" << (notify ? "" : ". Disabled notification");
if (host->GetState() == HostUp)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
host->AddComment(CommentAcknowledgement, arguments[5], arguments[6], 0);
- host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
+ host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, timestamp);
}
void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vector<String>& arguments)