Log(LogInformation, "icinga", "Setting acknowledgement for service '" + service->GetName() + "'");
- service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal);
+ service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal);
}
void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::vector<String>& arguments)
Log(LogInformation, "icinga", "Setting timed acknowledgement for service '" + service->GetName() + "'");
- service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
+ service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
}
void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vector<String>& arguments)
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
- service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal);
+ service->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal);
}
}
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
- service->AcknowledgeProblem(sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
+ service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, timestamp);
}
}
call_eventhandler = true;
}
+ bool remove_acknowledgement_comments = false;
+
+ if (GetAcknowledgement() == AcknowledgementNone)
+ remove_acknowledgement_comments = true;
+
bool hardChange = (GetStateType() == StateTypeHard && old_stateType == StateTypeSoft);
if (old_state != GetState() && old_stateType == StateTypeHard && GetStateType() == StateTypeHard)
olock.Unlock();
+ if (remove_acknowledgement_comments)
+ RemoveCommentsByType(CommentAcknowledgement);
+
Dictionary::Ptr vars_after = boost::make_shared<Dictionary>();
vars_after->Set("state", GetState());
vars_after->Set("state_type", GetStateType());
}
}
+void Service::RemoveCommentsByType(int type)
+{
+ Dictionary::Ptr comments = GetComments();
+
+ if (!comments)
+ return;
+
+ std::vector<String> removedComments;
+
+ {
+ ObjectLock olock(comments);
+
+ String id;
+ Dictionary::Ptr comment;
+ BOOST_FOREACH(tie(id, comment), comments) {
+ if (comment->Get("entry_type") == type)
+ removedComments.push_back(id);
+ }
+ }
+
+ if (!removedComments.empty()) {
+ BOOST_FOREACH(const String& id, removedComments) {
+ comments->Remove(id);
+ }
+
+ ObjectLock olock(this);
+ Touch("comments");
+ }
+}
+
void Service::RemoveExpiredComments(void)
{
Dictionary::Ptr comments = GetComments();
Touch("acknowledgement_expiry");
}
-void Service::AcknowledgeProblem(AcknowledgementType type, double expiry)
+void Service::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry)
{
{
ObjectLock olock(this);
SetAcknowledgementExpiry(expiry);
}
+ (void) AddComment(CommentAcknowledgement, author, comment, 0);
+
RequestNotifications(NotificationAcknowledgement, GetLastCheckResult());
}
static void UpdateStatistics(const Dictionary::Ptr& cr);
- void AcknowledgeProblem(AcknowledgementType type, double expiry = 0);
+ void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0);
void ClearAcknowledgement(void);
void ExecuteCheck(void);
const String& text, double expireTime);
void RemoveAllComments(void);
+ void RemoveCommentsByType(int type);
static void RemoveComment(const String& id);
static String GetCommentIDFromLegacyID(int id);