mirror of https://github.com/Icinga/icinga2.git
Extend Checkable::OnAcknowledgementCleared by removedBy
This commit is contained in:
parent
4e74eff7a2
commit
ea5403a55c
|
@ -244,8 +244,10 @@ Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& objec
|
|||
"Cannot remove acknowledgement for non-existent checkable object "
|
||||
+ object->GetName() + ".");
|
||||
|
||||
checkable->ClearAcknowledgement();
|
||||
checkable->RemoveCommentsByType(CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"));
|
||||
String removedBy (HttpUtility::GetLastParameter(params, "author"));
|
||||
|
||||
checkable->ClearAcknowledgement(removedBy);
|
||||
checkable->RemoveCommentsByType(CommentAcknowledgement, removedBy);
|
||||
|
||||
return ApiActions::CreateResult(200, "Successfully removed acknowledgement for object '" + checkable->GetName() + "'.");
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ void ApiEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
|||
inboxes.Push(std::move(result));
|
||||
}
|
||||
|
||||
void ApiEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
|
||||
void ApiEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
std::vector<EventQueue::Ptr> queues = EventQueue::GetQueuesForType("AcknowledgementCleared");
|
||||
auto inboxes (EventsRouter::GetInstance().GetInboxes(EventType::AcknowledgementCleared));
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
static void AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
||||
const String& author, const String& comment, AcknowledgementType type,
|
||||
bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin);
|
||||
|
||||
static void CommentAddedHandler(const Comment::Ptr& comment);
|
||||
static void CommentRemovedHandler(const Comment::Ptr& comment);
|
||||
|
|
|
@ -267,7 +267,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
|||
/* remove acknowledgements */
|
||||
if (GetAcknowledgement() == AcknowledgementNormal ||
|
||||
(GetAcknowledgement() == AcknowledgementSticky && IsStateOK(new_state))) {
|
||||
ClearAcknowledgement();
|
||||
ClearAcknowledgement("");
|
||||
}
|
||||
|
||||
/* reschedule direct parents */
|
||||
|
|
|
@ -16,7 +16,7 @@ REGISTER_TYPE_WITH_PROTOTYPE(Checkable, Checkable::GetPrototype());
|
|||
INITIALIZE_ONCE(&Checkable::StaticInitialize);
|
||||
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, bool, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||
|
||||
static Timer::Ptr l_CheckablesFireSuppressedNotifications;
|
||||
|
||||
|
@ -110,7 +110,7 @@ AcknowledgementType Checkable::GetAcknowledgement()
|
|||
|
||||
if (expiry != 0 && expiry < Utility::GetTime()) {
|
||||
avalue = AcknowledgementNone;
|
||||
ClearAcknowledgement();
|
||||
ClearAcknowledgement("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
|
|||
OnAcknowledgementSet(this, author, comment, type, notify, persistent, expiry, origin);
|
||||
}
|
||||
|
||||
void Checkable::ClearAcknowledgement(const MessageOrigin::Ptr& origin)
|
||||
void Checkable::ClearAcknowledgement(const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
SetAcknowledgementRaw(AcknowledgementNone);
|
||||
SetAcknowledgementExpiry(0);
|
||||
|
@ -144,7 +144,7 @@ void Checkable::ClearAcknowledgement(const MessageOrigin::Ptr& origin)
|
|||
Log(LogInformation, "Checkable")
|
||||
<< "Acknowledgement cleared for checkable '" << GetName() << "'.";
|
||||
|
||||
OnAcknowledgementCleared(this, origin);
|
||||
OnAcknowledgementCleared(this, removedBy, origin);
|
||||
}
|
||||
|
||||
Endpoint::Ptr Checkable::GetCommandEndpoint() const
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
AcknowledgementType GetAcknowledgement();
|
||||
|
||||
void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, bool persistent = false, double expiry = 0, const MessageOrigin::Ptr& origin = nullptr);
|
||||
void ClearAcknowledgement(const MessageOrigin::Ptr& origin = nullptr);
|
||||
void ClearAcknowledgement(const String& removedBy, const MessageOrigin::Ptr& origin = nullptr);
|
||||
|
||||
int GetSeverity() const override;
|
||||
bool GetProblem() const override;
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
const String&, const MessageOrigin::Ptr&)> OnNotificationSentToAllUsers;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType,
|
||||
bool, bool, double, const MessageOrigin::Ptr&)> OnAcknowledgementSet;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&)> OnNextCheckUpdated;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted;
|
||||
|
||||
|
|
|
@ -542,7 +542,7 @@ Value ClusterEvents::AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& orig
|
|||
return Empty;
|
||||
}
|
||||
|
||||
void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
|
||||
void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
|
||||
|
@ -557,6 +557,7 @@ void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkabl
|
|||
params->Set("host", host->GetName());
|
||||
if (service)
|
||||
params->Set("service", service->GetShortName());
|
||||
params->Set("author", removedBy);
|
||||
|
||||
Dictionary::Ptr message = new Dictionary();
|
||||
message->Set("jsonrpc", "2.0");
|
||||
|
@ -598,7 +599,7 @@ Value ClusterEvents::AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr&
|
|||
return Empty;
|
||||
}
|
||||
|
||||
checkable->ClearAcknowledgement(origin);
|
||||
checkable->ClearAcknowledgement(params->Get("author"), origin);
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin);
|
||||
static Value AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
||||
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin);
|
||||
static Value AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
||||
|
||||
static Value ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
||||
|
|
|
@ -639,7 +639,7 @@ void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto
|
|||
|
||||
{
|
||||
ObjectLock olock(service);
|
||||
service->ClearAcknowledgement();
|
||||
service->ClearAcknowledgement("");
|
||||
}
|
||||
|
||||
service->RemoveCommentsByType(CommentAcknowledgement);
|
||||
|
@ -703,7 +703,7 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect
|
|||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
host->ClearAcknowledgement();
|
||||
host->ClearAcknowledgement("");
|
||||
}
|
||||
host->RemoveCommentsByType(CommentAcknowledgement);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void IcingaDB::ConfigStaticInitialize()
|
|||
});
|
||||
|
||||
/* triggered when acknowledged host/service goes back to ok and when the acknowledgement gets deleted */
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const MessageOrigin::Ptr&) {
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String&, const MessageOrigin::Ptr&) {
|
||||
IcingaDB::StateChangeHandler(checkable);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue