},
%attribute array "groups" {
%attribute name(UserGroup) "*"
- }
+ },
+
+ %attribute dictionary "times" {
+ %attribute number "begin",
+ %attribute number "end",
+ },
}
},
}
},
%attribute array "groups" {
%attribute name(UserGroup) "*"
- }
+ },
+
+ %attribute dictionary "times" {
+ %attribute number "begin",
+ %attribute number "end",
+ },
}
},
},
%attribute array "groups" {
%attribute name(UserGroup) "*"
- }
+ },
+
+ %attribute dictionary "times" {
+ %attribute number "begin",
+ %attribute number "end",
+ },
+
}
}
}
%attribute name(UserGroup) "*"
},
+ %attribute dictionary "times" {
+ %attribute number "begin",
+ %attribute number "end",
+ },
+
%attribute array "notification_command" {
%attribute string "*"
},
RegisterAttribute("macros", Attribute_Config, &m_Macros);
RegisterAttribute("users", Attribute_Config, &m_Users);
RegisterAttribute("groups", Attribute_Config, &m_Groups);
+ RegisterAttribute("times", Attribute_Config, &m_Times);
RegisterAttribute("host_name", Attribute_Config, &m_HostName);
RegisterAttribute("service", Attribute_Config, &m_Service);
RegisterAttribute("export_macros", Attribute_Config, &m_ExportMacros);
return result;
}
+Dictionary::Ptr Notification::GetTimes(void) const
+{
+ return m_Times;
+}
+
double Notification::GetNotificationInterval(void) const
{
if (m_NotificationInterval.IsEmpty())
}
}
-void Notification::BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool ignore_timeperiod)
+void Notification::BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool force)
{
ASSERT(!OwnsLock());
- if (!ignore_timeperiod) {
+ if (!force) {
TimePeriod::Ptr tp = GetNotificationPeriod();
if (tp && !tp->IsInside(Utility::GetTime())) {
Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': not in timeperiod");
return;
}
+
+ double now = Utility::GetTime();
+ Dictionary::Ptr times = GetTimes();
+ Service::Ptr service = GetService();
+
+ if (times && times->Contains("begin") && now < service->GetLastHardStateChange() + times->Get("begin")) {
+ Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': before escalation range");
+ return;
+ }
+
+ if (times && times->Contains("end") && now > service->GetLastHardStateChange() + times->Get("end")) {
+ Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': after escalation range");
+ return;
+ }
}
{
BOOST_FOREACH(const User::Ptr& user, allUsers) {
Log(LogDebug, "icinga", "Sending notification for user " + user->GetName());
- Utility::QueueAsyncCallback(boost::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, ignore_timeperiod));
+ Utility::QueueAsyncCallback(boost::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, force));
}
}
Array::Ptr GetExportMacros(void) const;
std::set<User::Ptr> GetUsers(void) const;
std::set<UserGroup::Ptr> GetGroups(void) const;
+ Dictionary::Ptr GetTimes(void) const;
double GetLastNotification(void) const;
void SetLastNotification(double time);
double GetNextNotification(void) const;
void SetNextNotification(double time);
- void BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool ignore_timeperiod);
+ void BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr, bool force);
static String NotificationTypeToString(NotificationType type);
Attribute<Array::Ptr> m_ExportMacros;
Attribute<Array::Ptr> m_Users;
Attribute<Array::Ptr> m_Groups;
+ Attribute<Dictionary::Ptr> m_Times;
Attribute<String> m_HostName;
Attribute<String> m_Service;
- void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool ignore_timeperiod);
+ void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const Dictionary::Ptr& cr, bool force);
};
}