mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7690 from Icinga/feature/flapping-acknowledgement-start-time-7689
IcingaDB: include consistent IDs, start time and end time in icinga:history:stream:{flapping,acknowledgement}
This commit is contained in:
commit
77e02031f9
|
@ -49,7 +49,7 @@ void DbEvents::StaticInitialize()
|
|||
/* History */
|
||||
Comment::OnCommentAdded.connect(std::bind(&DbEvents::AddCommentHistory, _1));
|
||||
Downtime::OnDowntimeAdded.connect(std::bind(&DbEvents::AddDowntimeHistory, _1));
|
||||
Checkable::OnAcknowledgementSet.connect(std::bind(&DbEvents::AddAcknowledgementHistory, _1, _2, _3, _4, _5, _6));
|
||||
Checkable::OnAcknowledgementSet.connect(std::bind(&DbEvents::AddAcknowledgementHistory, _1, _2, _3, _4, _5, _7));
|
||||
|
||||
Checkable::OnNotificationSentToAllUsers.connect(std::bind(&DbEvents::AddNotificationHistory, _1, _2, _3, _4, _5, _6, _7));
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object,
|
|||
Comment::AddComment(checkable, CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"),
|
||||
HttpUtility::GetLastParameter(params, "comment"), persistent, timestamp);
|
||||
checkable->AcknowledgeProblem(HttpUtility::GetLastParameter(params, "author"),
|
||||
HttpUtility::GetLastParameter(params, "comment"), sticky, notify, persistent, timestamp);
|
||||
HttpUtility::GetLastParameter(params, "comment"), sticky, notify, persistent, Utility::GetTime(), timestamp);
|
||||
|
||||
return ApiActions::CreateResult(200, "Successfully acknowledged problem for object '" + checkable->GetName() + "'.");
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ void ApiEvents::FlappingChangedHandler(const Checkable::Ptr& checkable, const Me
|
|||
|
||||
void ApiEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
||||
const String& author, const String& comment, AcknowledgementType type,
|
||||
bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin)
|
||||
bool notify, bool persistent, double, double expiry, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
std::vector<EventQueue::Ptr> queues = EventQueue::GetQueuesForType("AcknowledgementSet");
|
||||
auto inboxes (EventsRouter::GetInstance().GetInboxes(EventType::AcknowledgementSet));
|
||||
|
@ -221,7 +221,7 @@ void ApiEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
|||
inboxes.Push(std::move(result));
|
||||
}
|
||||
|
||||
void ApiEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
void ApiEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
std::vector<EventQueue::Ptr> queues = EventQueue::GetQueuesForType("AcknowledgementCleared");
|
||||
auto inboxes (EventsRouter::GetInstance().GetInboxes(EventType::AcknowledgementCleared));
|
||||
|
|
|
@ -29,8 +29,8 @@ 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 String& removedBy, const MessageOrigin::Ptr& origin);
|
||||
bool notify, bool persistent, double, double expiry, const MessageOrigin::Ptr& origin);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double, const MessageOrigin::Ptr& origin);
|
||||
|
||||
static void CommentAddedHandler(const Comment::Ptr& comment);
|
||||
static void CommentRemovedHandler(const Comment::Ptr& comment);
|
||||
|
|
|
@ -64,10 +64,16 @@ void Checkable::UpdateFlappingStatus(bool stateChange)
|
|||
SetFlappingBuffer(stateChangeBuf.GetValue());
|
||||
SetFlappingIndex(oldestIndex);
|
||||
SetFlappingCurrent(flappingValue);
|
||||
SetFlapping(flapping, true);
|
||||
|
||||
if (flapping != GetFlapping())
|
||||
SetFlappingLastChange(Utility::GetTime());
|
||||
if (flapping != GetFlapping()) {
|
||||
SetFlapping(flapping, true);
|
||||
|
||||
double ee = GetLastCheckResult()->GetExecutionEnd();
|
||||
|
||||
OnFlappingChange(this, ee);
|
||||
|
||||
SetFlappingLastChange(ee);
|
||||
}
|
||||
}
|
||||
|
||||
bool Checkable::IsFlapping() const
|
||||
|
|
|
@ -15,8 +15,9 @@ using namespace icinga;
|
|||
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 String&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, bool, double, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
||||
|
||||
static Timer::Ptr l_CheckablesFireSuppressedNotifications;
|
||||
|
||||
|
@ -122,7 +123,7 @@ bool Checkable::IsAcknowledged() const
|
|||
return const_cast<Checkable *>(this)->GetAcknowledgement() != AcknowledgementNone;
|
||||
}
|
||||
|
||||
void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin)
|
||||
void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, bool persistent, double changeTime, double expiry, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
SetAcknowledgementRaw(type);
|
||||
SetAcknowledgementExpiry(expiry);
|
||||
|
@ -133,10 +134,12 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
|
|||
Log(LogInformation, "Checkable")
|
||||
<< "Acknowledgement set for checkable '" << GetName() << "'.";
|
||||
|
||||
OnAcknowledgementSet(this, author, comment, type, notify, persistent, expiry, origin);
|
||||
OnAcknowledgementSet(this, author, comment, type, notify, persistent, changeTime, expiry, origin);
|
||||
|
||||
SetAcknowledgementLastChange(changeTime);
|
||||
}
|
||||
|
||||
void Checkable::ClearAcknowledgement(const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
void Checkable::ClearAcknowledgement(const String& removedBy, double changeTime, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
ObjectLock oLock (this);
|
||||
|
||||
|
@ -157,7 +160,9 @@ void Checkable::ClearAcknowledgement(const String& removedBy, const MessageOrigi
|
|||
<< "Acknowledgement cleared for checkable '" << GetName() << "'.";
|
||||
|
||||
if (wasAcked) {
|
||||
OnAcknowledgementCleared(this, removedBy, origin);
|
||||
OnAcknowledgementCleared(this, removedBy, changeTime, origin);
|
||||
|
||||
SetAcknowledgementLastChange(changeTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ 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 String& removedBy, const MessageOrigin::Ptr& origin = nullptr);
|
||||
void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, bool persistent = false, double changeTime = Utility::GetTime(), double expiry = 0, const MessageOrigin::Ptr& origin = nullptr);
|
||||
void ClearAcknowledgement(const String& removedBy, double changeTime = Utility::GetTime(), const MessageOrigin::Ptr& origin = nullptr);
|
||||
|
||||
int GetSeverity() const override;
|
||||
bool GetProblem() const override;
|
||||
|
@ -112,8 +112,9 @@ public:
|
|||
const NotificationType&, const CheckResult::Ptr&, const String&,
|
||||
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 String&, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
|
||||
bool, bool, double, double, const MessageOrigin::Ptr&)> OnAcknowledgementSet;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&, double)> OnFlappingChange;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&)> OnNextCheckUpdated;
|
||||
static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted;
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ abstract class Checkable : CustomVarObject
|
|||
default {{{ return AcknowledgementNone; }}}
|
||||
};
|
||||
[state] Timestamp acknowledgement_expiry;
|
||||
[state] Timestamp acknowledgement_last_change;
|
||||
[state] bool force_next_notification;
|
||||
[no_storage] Timestamp last_check {
|
||||
get;
|
||||
|
|
|
@ -473,7 +473,7 @@ Value ClusterEvents::ForceNextNotificationChangedAPIHandler(const MessageOrigin:
|
|||
|
||||
void ClusterEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
||||
const String& author, const String& comment, AcknowledgementType type,
|
||||
bool notify, bool persistent, double expiry, const MessageOrigin::Ptr& origin)
|
||||
bool notify, bool persistent, double changeTime, double expiry, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
|
||||
|
@ -494,6 +494,7 @@ void ClusterEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
|
|||
params->Set("notify", notify);
|
||||
params->Set("persistent", persistent);
|
||||
params->Set("expiry", expiry);
|
||||
params->Set("change_time", changeTime);
|
||||
|
||||
Dictionary::Ptr message = new Dictionary();
|
||||
message->Set("jsonrpc", "2.0");
|
||||
|
@ -546,12 +547,12 @@ Value ClusterEvents::AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& orig
|
|||
|
||||
checkable->AcknowledgeProblem(params->Get("author"), params->Get("comment"),
|
||||
static_cast<AcknowledgementType>(static_cast<int>(params->Get("acktype"))),
|
||||
params->Get("notify"), params->Get("persistent"), params->Get("expiry"), origin);
|
||||
params->Get("notify"), params->Get("persistent"), params->Get("change_time"), params->Get("expiry"), origin);
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
||||
void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr& origin)
|
||||
void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
|
||||
|
@ -567,6 +568,7 @@ void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkabl
|
|||
if (service)
|
||||
params->Set("service", service->GetShortName());
|
||||
params->Set("author", removedBy);
|
||||
params->Set("change_time", changeTime);
|
||||
|
||||
Dictionary::Ptr message = new Dictionary();
|
||||
message->Set("jsonrpc", "2.0");
|
||||
|
@ -608,7 +610,7 @@ Value ClusterEvents::AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr&
|
|||
return Empty;
|
||||
}
|
||||
|
||||
checkable->ClearAcknowledgement(params->Get("author"), origin);
|
||||
checkable->ClearAcknowledgement(params->Get("author"), params->Get("change_time"), origin);
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@ public:
|
|||
static Value ForceNextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
||||
|
||||
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);
|
||||
bool notify, bool persistent, double changeTime, 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 String& removedBy, const MessageOrigin::Ptr& origin);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime, 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);
|
||||
|
|
|
@ -60,15 +60,15 @@ void IcingaDB::ConfigStaticInitialize()
|
|||
IcingaDB::StateChangeHandler(checkable, cr, type);
|
||||
});
|
||||
|
||||
Checkable::OnAcknowledgementSet.connect([](const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool, bool persistent, double expiry, const MessageOrigin::Ptr&) {
|
||||
AcknowledgementSetHandler(checkable, author, comment, type, persistent, expiry);
|
||||
Checkable::OnAcknowledgementSet.connect([](const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool, bool persistent, double changeTime, double expiry, const MessageOrigin::Ptr&) {
|
||||
AcknowledgementSetHandler(checkable, author, comment, type, persistent, changeTime, expiry);
|
||||
});
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String& removedBy, const MessageOrigin::Ptr&) {
|
||||
AcknowledgementClearedHandler(checkable, removedBy);
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String& removedBy, double changeTime, const MessageOrigin::Ptr&) {
|
||||
AcknowledgementClearedHandler(checkable, removedBy, changeTime);
|
||||
});
|
||||
|
||||
/* triggered when acknowledged host/service goes back to ok and when the acknowledgement gets deleted */
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String&, const MessageOrigin::Ptr&) {
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String&, double, const MessageOrigin::Ptr&) {
|
||||
IcingaDB::StateChangeHandler(checkable);
|
||||
});
|
||||
|
||||
|
@ -96,7 +96,7 @@ void IcingaDB::ConfigStaticInitialize()
|
|||
Comment::OnCommentAdded.connect(&IcingaDB::CommentAddedHandler);
|
||||
Comment::OnCommentRemoved.connect(&IcingaDB::CommentRemovedHandler);
|
||||
|
||||
Checkable::OnFlappingChanged.connect(&IcingaDB::FlappingChangedHandler);
|
||||
Checkable::OnFlappingChange.connect(&IcingaDB::FlappingChangeHandler);
|
||||
|
||||
Checkable::OnNewCheckResult.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr&, const MessageOrigin::Ptr&) {
|
||||
IcingaDB::NewCheckResultHandler(checkable);
|
||||
|
@ -1615,7 +1615,7 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
|
|||
m_Rcon->FireAndForgetQuery(std::move(xAdd), Prio::History);
|
||||
}
|
||||
|
||||
void IcingaDB::SendFlappingChanged(const Checkable::Ptr& checkable, const Value& value)
|
||||
void IcingaDB::SendFlappingChange(const Checkable::Ptr& checkable, double changeTime, double flappingLastChange)
|
||||
{
|
||||
if (!m_Rcon || !m_Rcon->IsConnected())
|
||||
return;
|
||||
|
@ -1626,15 +1626,12 @@ void IcingaDB::SendFlappingChanged(const Checkable::Ptr& checkable, const Value&
|
|||
|
||||
std::vector<String> xAdd ({
|
||||
"XADD", "icinga:history:stream:flapping", "*",
|
||||
"id", Utility::NewUniqueID(),
|
||||
"environment_id", SHA1(GetEnvironment()),
|
||||
"host_id", GetObjectIdentifier(host),
|
||||
"percent_state_change", Convert::ToString(checkable->GetFlappingCurrent()),
|
||||
"flapping_threshold_low", Convert::ToString(checkable->GetFlappingThresholdLow()),
|
||||
"flapping_threshold_high", Convert::ToString(checkable->GetFlappingThresholdHigh()),
|
||||
"event_time", Convert::ToString(TimestampToMilliseconds(Utility::GetTime())),
|
||||
"event_id", Utility::NewUniqueID(),
|
||||
"event_type", value.ToBool() ? "flapping_start" : "flapping_end"
|
||||
"event_id", Utility::NewUniqueID()
|
||||
});
|
||||
|
||||
if (service) {
|
||||
|
@ -1654,6 +1651,27 @@ void IcingaDB::SendFlappingChanged(const Checkable::Ptr& checkable, const Value&
|
|||
xAdd.emplace_back(GetObjectIdentifier(endpoint));
|
||||
}
|
||||
|
||||
long long startTime;
|
||||
|
||||
if (checkable->IsFlapping()) {
|
||||
startTime = TimestampToMilliseconds(changeTime);
|
||||
|
||||
xAdd.emplace_back("event_type");
|
||||
xAdd.emplace_back("flapping_start");
|
||||
} else {
|
||||
startTime = TimestampToMilliseconds(flappingLastChange);
|
||||
|
||||
xAdd.emplace_back("event_type");
|
||||
xAdd.emplace_back("flapping_end");
|
||||
xAdd.emplace_back("end_time");
|
||||
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(changeTime)));
|
||||
}
|
||||
|
||||
xAdd.emplace_back("start_time");
|
||||
xAdd.emplace_back(Convert::ToString(startTime));
|
||||
xAdd.emplace_back("id");
|
||||
xAdd.emplace_back(HashValue(new Array({GetEnvironment(), checkable->GetReflectionType()->GetName(), checkable->GetName(), startTime})));
|
||||
|
||||
m_Rcon->FireAndForgetQuery(std::move(xAdd), Prio::History);
|
||||
}
|
||||
|
||||
|
@ -1673,7 +1691,7 @@ void IcingaDB::SendNextUpdate(const Checkable::Ptr& checkable)
|
|||
);
|
||||
}
|
||||
|
||||
void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double expiry)
|
||||
void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry)
|
||||
{
|
||||
if (!m_Rcon || !m_Rcon->IsConnected())
|
||||
return;
|
||||
|
@ -1684,10 +1702,9 @@ void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const Str
|
|||
|
||||
std::vector<String> xAdd ({
|
||||
"XADD", "icinga:history:stream:acknowledgement", "*",
|
||||
"id", Utility::NewUniqueID(),
|
||||
"event_id", Utility::NewUniqueID(),
|
||||
"environment_id", SHA1(GetEnvironment()),
|
||||
"host_id", GetObjectIdentifier(host),
|
||||
"event_time", Convert::ToString(TimestampToMilliseconds(Utility::GetTime())),
|
||||
"event_type", "ack_set",
|
||||
"author", author,
|
||||
"comment", comment,
|
||||
|
@ -1717,10 +1734,17 @@ void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const Str
|
|||
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expiry)));
|
||||
}
|
||||
|
||||
long long setTime = TimestampToMilliseconds(changeTime);
|
||||
|
||||
xAdd.emplace_back("set_time");
|
||||
xAdd.emplace_back(Convert::ToString(setTime));
|
||||
xAdd.emplace_back("id");
|
||||
xAdd.emplace_back(HashValue(new Array({GetEnvironment(), checkable->GetReflectionType()->GetName(), checkable->GetName(), setTime})));
|
||||
|
||||
m_Rcon->FireAndForgetQuery(std::move(xAdd), Prio::History);
|
||||
}
|
||||
|
||||
void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const String& removedBy)
|
||||
void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const String& removedBy, double changeTime, double ackLastChange)
|
||||
{
|
||||
if (!m_Rcon || !m_Rcon->IsConnected())
|
||||
return;
|
||||
|
@ -1731,12 +1755,11 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
|
|||
|
||||
std::vector<String> xAdd ({
|
||||
"XADD", "icinga:history:stream:acknowledgement", "*",
|
||||
"id", Utility::NewUniqueID(),
|
||||
"event_id", Utility::NewUniqueID(),
|
||||
"environment_id", SHA1(GetEnvironment()),
|
||||
"host_id", GetObjectIdentifier(host),
|
||||
"event_time", Convert::ToString(TimestampToMilliseconds(Utility::GetTime())),
|
||||
"event_type", "ack_clear",
|
||||
"author", removedBy
|
||||
"clear_time", Convert::ToString(TimestampToMilliseconds(changeTime)),
|
||||
"event_type", "ack_clear"
|
||||
});
|
||||
|
||||
if (service) {
|
||||
|
@ -1756,6 +1779,18 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
|
|||
xAdd.emplace_back(GetObjectIdentifier(endpoint));
|
||||
}
|
||||
|
||||
long long setTime = TimestampToMilliseconds(ackLastChange);
|
||||
|
||||
xAdd.emplace_back("set_time");
|
||||
xAdd.emplace_back(Convert::ToString(setTime));
|
||||
xAdd.emplace_back("id");
|
||||
xAdd.emplace_back(HashValue(new Array({GetEnvironment(), checkable->GetReflectionType()->GetName(), checkable->GetName(), setTime})));
|
||||
|
||||
if (!removedBy.IsEmpty()) {
|
||||
xAdd.emplace_back("cleared_by");
|
||||
xAdd.emplace_back(removedBy);
|
||||
}
|
||||
|
||||
m_Rcon->FireAndForgetQuery(std::move(xAdd), Prio::History);
|
||||
}
|
||||
|
||||
|
@ -1991,10 +2026,12 @@ void IcingaDB::CommentRemovedHandler(const Comment::Ptr& comment)
|
|||
}
|
||||
}
|
||||
|
||||
void IcingaDB::FlappingChangedHandler(const Checkable::Ptr& checkable, const Value& value)
|
||||
void IcingaDB::FlappingChangeHandler(const Checkable::Ptr& checkable, double changeTime)
|
||||
{
|
||||
auto flappingLastChange (checkable->GetFlappingLastChange());
|
||||
|
||||
for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, value]() { rw->SendFlappingChanged(checkable, value); });
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, changeTime, flappingLastChange]() { rw->SendFlappingChange(checkable, changeTime, flappingLastChange); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2011,7 +2048,7 @@ struct AuthorComment
|
|||
String Comment;
|
||||
};
|
||||
|
||||
void IcingaDB::AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double expiry)
|
||||
void IcingaDB::AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry)
|
||||
{
|
||||
auto rws (ConfigType::GetObjectsByType<IcingaDB>());
|
||||
|
||||
|
@ -2019,20 +2056,21 @@ void IcingaDB::AcknowledgementSetHandler(const Checkable::Ptr& checkable, const
|
|||
auto ac (Shared<AuthorComment>::Make(AuthorComment{author, comment}));
|
||||
|
||||
for (auto& rw : rws) {
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, ac, type, persistent, expiry]() { rw->SendAcknowledgementSet(checkable, ac->Author, ac->Comment, type, persistent, expiry); });
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, ac, type, persistent, changeTime, expiry]() { rw->SendAcknowledgementSet(checkable, ac->Author, ac->Comment, type, persistent, changeTime, expiry); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IcingaDB::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy)
|
||||
void IcingaDB::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime)
|
||||
{
|
||||
auto rws (ConfigType::GetObjectsByType<IcingaDB>());
|
||||
|
||||
if (!rws.empty()) {
|
||||
auto rb (Shared<String>::Make(removedBy));
|
||||
auto ackLastChange (checkable->GetAcknowledgementLastChange());
|
||||
|
||||
for (auto& rw : rws) {
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, rb]() { rw->SendAcknowledgementCleared(checkable, *rb); });
|
||||
rw->m_WorkQueue.Enqueue([rw, checkable, rb, changeTime, ackLastChange]() { rw->SendAcknowledgementCleared(checkable, *rb, changeTime, ackLastChange); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ private:
|
|||
void SendRemovedDowntime(const Downtime::Ptr& downtime);
|
||||
void SendAddedComment(const Comment::Ptr& comment);
|
||||
void SendRemovedComment(const Comment::Ptr& comment);
|
||||
void SendFlappingChanged(const Checkable::Ptr& checkable, const Value& value);
|
||||
void SendFlappingChange(const Checkable::Ptr& checkable, double changeTime, double flappingLastChange);
|
||||
void SendNextUpdate(const Checkable::Ptr& checkable);
|
||||
void SendAcknowledgementSet(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double expiry);
|
||||
void SendAcknowledgementCleared(const Checkable::Ptr& checkable, const String& removedBy);
|
||||
void SendAcknowledgementSet(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry);
|
||||
void SendAcknowledgementCleared(const Checkable::Ptr& checkable, const String& removedBy, double changeTime, double ackLastChange);
|
||||
|
||||
std::vector<String> UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType, const String& typeNameOverride);
|
||||
Dictionary::Ptr SerializeState(const Checkable::Ptr& checkable);
|
||||
|
@ -106,10 +106,10 @@ private:
|
|||
|
||||
static void CommentAddedHandler(const Comment::Ptr& comment);
|
||||
static void CommentRemovedHandler(const Comment::Ptr& comment);
|
||||
static void FlappingChangedHandler(const Checkable::Ptr& checkable, const Value& value);
|
||||
static void FlappingChangeHandler(const Checkable::Ptr& checkable, double changeTime);
|
||||
static void NewCheckResultHandler(const Checkable::Ptr& checkable);
|
||||
static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double expiry);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy);
|
||||
static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry);
|
||||
static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime);
|
||||
|
||||
void AssertOnWorkQueue();
|
||||
|
||||
|
|
Loading…
Reference in New Issue