if (is_volatile && IsStateOK(old_state) && IsStateOK(new_state))
send_notification = false; /* Don't send notifications for volatile OK -> OK changes. */
- bool send_downtime_notification = (GetLastInDowntime() != in_downtime);
SetLastInDowntime(in_downtime);
olock.Unlock();
(is_volatile && !(IsStateOK(old_state) && IsStateOK(new_state))))
ExecuteEventHandler();
- if (send_downtime_notification && IsActive())
- OnNotificationsRequested(this, in_downtime ? NotificationDowntimeStart : NotificationDowntimeEnd, cr, "", "", MessageOrigin::Ptr());
-
/* Flapping start/end notifications */
if (!was_flapping && is_flapping) {
if (!IsPaused())
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, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
+void Checkable::StaticInitialize(void)
+{
+ /* fixed downtime start */
+ Downtime::OnDowntimeAdded.connect(boost::bind(&Checkable::NotifyFixedDowntimeStart, _1));
+ /* flexible downtime start */
+ Downtime::OnDowntimeTriggered.connect(boost::bind(&Checkable::NotifyFlexibleDowntimeStart, _1));
+ /* fixed/flexible downtime end */
+ Downtime::OnDowntimeRemoved.connect(boost::bind(&Checkable::NotifyDowntimeEnd, _1));
+}
+
Checkable::Checkable(void)
: m_CheckRunning(false)
{
return Endpoint::GetByName(GetCommandEndpointRaw());
}
+void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime)
+{
+ if (!downtime->GetFixed())
+ return;
+
+ NotifyDowntimeInternal(downtime);
+}
+
+void Checkable::NotifyFlexibleDowntimeStart(const Downtime::Ptr& downtime)
+{
+ if (downtime->GetFixed())
+ return;
+
+ NotifyDowntimeInternal(downtime);
+}
+
+void Checkable::NotifyDowntimeInternal(const Downtime::Ptr& downtime)
+{
+ Checkable::Ptr checkable = downtime->GetCheckable();
+
+ if (!checkable->IsPaused())
+ OnNotificationsRequested(checkable, NotificationDowntimeStart, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), MessageOrigin::Ptr());
+}
+
+void Checkable::NotifyDowntimeEnd(const Downtime::Ptr& downtime)
+{
+ Checkable::Ptr checkable = downtime->GetCheckable();
+
+ if (!checkable->IsPaused())
+ OnNotificationsRequested(checkable, NotificationDowntimeEnd, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), MessageOrigin::Ptr());
+}
+
void Checkable::ValidateCheckInterval(double value, const ValidationUtils& utils)
{
ObjectImpl<Checkable>::ValidateCheckInterval(value, utils);
DECLARE_OBJECT(Checkable);
DECLARE_OBJECTNAME(Checkable);
+ static void StaticInitialize(void);
+
Checkable(void);
std::set<Checkable::Ptr> GetParents(void) const;
std::set<Downtime::Ptr> m_Downtimes;
mutable boost::mutex m_DowntimeMutex;
+ static void NotifyFixedDowntimeStart(const Downtime::Ptr& downtime);
+ static void NotifyFlexibleDowntimeStart(const Downtime::Ptr& downtime);
+ static void NotifyDowntimeInternal(const Downtime::Ptr& downtime);
+
+ static void NotifyDowntimeEnd(const Downtime::Ptr& downtime);
+
/* Comments */
std::set<Comment::Ptr> m_Comments;
mutable boost::mutex m_CommentMutex;