mirror of https://github.com/Icinga/icinga2.git
DB IDO: Update Host/Service state 'last_notification' on NotificationSentToAllUsers.
Refs #6051
This commit is contained in:
parent
ba12ec2927
commit
fc44798b8d
|
@ -52,6 +52,7 @@ void DbEvents::StaticInitialize(void)
|
||||||
|
|
||||||
Checkable::OnNextCheckChanged.connect(bind(&DbEvents::NextCheckChangedHandler, _1, _2, _3));
|
Checkable::OnNextCheckChanged.connect(bind(&DbEvents::NextCheckChangedHandler, _1, _2, _3));
|
||||||
Checkable::OnFlappingChanged.connect(bind(&DbEvents::FlappingChangedHandler, _1, _2));
|
Checkable::OnFlappingChanged.connect(bind(&DbEvents::FlappingChangedHandler, _1, _2));
|
||||||
|
Checkable::OnNotificationSentToAllUsers.connect(bind(&DbEvents::LastNotificationChangedHandler, _1, _2));
|
||||||
|
|
||||||
/* History */
|
/* History */
|
||||||
Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddCommentHistory, _1, _2));
|
Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddCommentHistory, _1, _2));
|
||||||
|
@ -138,6 +139,42 @@ void DbEvents::FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingS
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DbEvents::LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable)
|
||||||
|
{
|
||||||
|
double now = Utility::GetTime();
|
||||||
|
std::pair<unsigned long, unsigned long> now_bag = CompatUtility::ConvertTimestamp(now);
|
||||||
|
std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(notification->GetNextNotification());
|
||||||
|
|
||||||
|
Host::Ptr host;
|
||||||
|
Service::Ptr service;
|
||||||
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
|
DbQuery query1;
|
||||||
|
if (service)
|
||||||
|
query1.Table = "servicestatus";
|
||||||
|
else
|
||||||
|
query1.Table = "hoststatus";
|
||||||
|
|
||||||
|
query1.Type = DbQueryUpdate;
|
||||||
|
|
||||||
|
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
||||||
|
fields1->Set("last_notification", DbValue::FromTimestamp(now_bag.first));
|
||||||
|
fields1->Set("next_notification", DbValue::FromTimestamp(time_bag.first));
|
||||||
|
fields1->Set("current_notification_number", notification->GetNotificationNumber());
|
||||||
|
|
||||||
|
query1.Fields = fields1;
|
||||||
|
|
||||||
|
query1.WhereCriteria = make_shared<Dictionary>();
|
||||||
|
if (service)
|
||||||
|
query1.WhereCriteria->Set("service_object_id", service);
|
||||||
|
else
|
||||||
|
query1.WhereCriteria->Set("host_object_id", host);
|
||||||
|
|
||||||
|
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
|
DbObject::OnQuery(query1);
|
||||||
|
}
|
||||||
|
|
||||||
/* comments */
|
/* comments */
|
||||||
void DbEvents::AddComments(const Checkable::Ptr& checkable)
|
void DbEvents::AddComments(const Checkable::Ptr& checkable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
/* Status */
|
/* Status */
|
||||||
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck, const String& authority);
|
static void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck, const String& authority);
|
||||||
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
||||||
|
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
||||||
static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
||||||
|
|
Loading…
Reference in New Issue