mirror of https://github.com/Icinga/icinga2.git
parent
e13a6ac23d
commit
1d7428b237
|
@ -492,7 +492,7 @@ void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<S
|
|||
|
||||
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)
|
||||
|
@ -510,7 +510,7 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve
|
|||
|
||||
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)
|
||||
|
@ -540,7 +540,7 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector<
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,6 +397,11 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||
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)
|
||||
|
@ -425,6 +430,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||
|
||||
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());
|
||||
|
|
|
@ -239,6 +239,36 @@ void Service::RefreshCommentsCache(void)
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -280,7 +280,7 @@ void Service::SetAcknowledgementExpiry(double timestamp)
|
|||
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);
|
||||
|
@ -289,6 +289,8 @@ void Service::AcknowledgeProblem(AcknowledgementType type, double expiry)
|
|||
SetAcknowledgementExpiry(expiry);
|
||||
}
|
||||
|
||||
(void) AddComment(CommentAcknowledgement, author, comment, 0);
|
||||
|
||||
RequestNotifications(NotificationAcknowledgement, GetLastCheckResult());
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
|
||||
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);
|
||||
|
@ -217,6 +217,7 @@ public:
|
|||
const String& text, double expireTime);
|
||||
|
||||
void RemoveAllComments(void);
|
||||
void RemoveCommentsByType(int type);
|
||||
static void RemoveComment(const String& id);
|
||||
|
||||
static String GetCommentIDFromLegacyID(int id);
|
||||
|
|
Loading…
Reference in New Issue