|
@@ -52,6 +52,7 @@ void DbEvents::StaticInitialize(void) |
|
|
|
|
|
Checkable::OnNextCheckChanged.connect(bind(&DbEvents::NextCheckChangedHandler, _1, _2, _3)); |
|
|
Checkable::OnFlappingChanged.connect(bind(&DbEvents::FlappingChangedHandler, _1, _2)); |
|
|
Checkable::OnNotificationSentToAllUsers.connect(bind(&DbEvents::LastNotificationChangedHandler, _1, _2)); |
|
|
|
|
|
/* History */ |
|
|
Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddCommentHistory, _1, _2)); |
|
@@ -138,6 +139,42 @@ void DbEvents::FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingS |
|
|
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 */ |
|
|
void DbEvents::AddComments(const Checkable::Ptr& checkable) |
|
|
{ |
|
|
0 comments on commit
fc44798