<< "\t" << "problem_has_been_acknowledged=" << (service->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
<< "\t" << "acknowledgement_type=" << static_cast<int>(service->GetAcknowledgement()) << "\n"
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
- << "\t" << "scheduled_downtime_depth=" << (service->IsInDowntime() ? 1 : 0) << "\n";
+ << "\t" << "scheduled_downtime_depth=" << (service->IsInDowntime() ? 1 : 0) << "\n"
+ << "\t" << "last_notification=" << service->GetLastNotification() << "\n"
+ << "\t" << "next_notification=" << service->GetNextNotification() << "\n";
}
void CompatComponent::DumpServiceStatus(ofstream& fp, const Service::Ptr& service)
service->RemoveExpiredDowntimes();
}
}
+
+bool Service::IsInDowntime(void) const
+{
+ Dictionary::Ptr downtimes = GetDowntimes();
+
+ if (!downtimes)
+ return false;
+
+ Dictionary::Ptr downtime;
+ BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
+ if (Service::IsDowntimeActive(downtime))
+ return true;
+ }
+
+ return false;
+}
EndpointManager::GetInstance()->SendAnycastMessage(Endpoint::Ptr(), msg);
}
-void Service::SendNotifications(NotificationType type) const
+void Service::SendNotifications(NotificationType type)
{
Logger::Write(LogInformation, "icinga", "Sending notifications for service '" + GetName() + "'");
BOOST_FOREACH(const Notification::Ptr& notification, notifications) {
notification->SendNotification(type);
}
+
+ SetLastNotification(Utility::GetTime());
}
void Service::InvalidateNotificationsCache(void)
Set("slave_notifications", newNotifications);
}
+
+double Service::GetLastNotification(void) const
+{
+ Value value = Get("last_notification");
+
+ if (value.IsEmpty())
+ value = 0;
+
+ return value;
+}
+
+void Service::SetLastNotification(double time)
+{
+ Set("last_notification", time);
+}
+
+double Service::GetNextNotification(void) const
+{
+ Value value = Get("next_notification");
+
+ if (value.IsEmpty())
+ value = 0;
+
+ return value;
+}
+
+void Service::SetNextNotification(double time)
+{
+ Set("next_notification", time);
+}
{ "acknowledgement", Attribute_Replicated },
{ "acknowledgement_expiry", Attribute_Replicated },
{ "downtimes", Attribute_Replicated },
- { "comments", Attribute_Replicated }
+ { "comments", Attribute_Replicated },
+ { "last_notification", Attribute_Replicated },
+ { "next_notification", Attribute_Replicated }
};
REGISTER_TYPE(Service, serviceAttributes);
return true;
}
-bool Service::IsInDowntime(void) const
-{
- Dictionary::Ptr downtimes = GetDowntimes();
-
- if (!downtimes)
- return false;
-
- Dictionary::Ptr downtime;
- BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
- if (Service::IsDowntimeActive(downtime))
- return true;
- }
-
- return false;
-}
-
void Service::SetSchedulingOffset(long offset)
{
Set("scheduling_offset", offset);
/* Notifications */
void RequestNotifications(NotificationType type) const;
- void SendNotifications(NotificationType type) const;
+ void SendNotifications(NotificationType type);
static void InvalidateNotificationsCache(void);
static void ValidateNotificationsCache(void);
void UpdateSlaveNotifications(void);
+ double GetLastNotification(void) const;
+ void SetLastNotification(double time);
+
+ double GetNextNotification(void) const;
+ void SetNextNotification(double time);
+
protected:
virtual void OnAttributeChanged(const String& name, const Value& oldValue);