mirror of https://github.com/Icinga/icinga2.git
Implement notification escalations.
This commit is contained in:
parent
f4d04f8172
commit
8e754b085e
|
@ -97,7 +97,12 @@ type Host {
|
|||
},
|
||||
%attribute array "groups" {
|
||||
%attribute name(UserGroup) "*"
|
||||
}
|
||||
},
|
||||
|
||||
%attribute dictionary "times" {
|
||||
%attribute number "begin",
|
||||
%attribute number "end",
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -122,7 +127,12 @@ type Host {
|
|||
},
|
||||
%attribute array "groups" {
|
||||
%attribute name(UserGroup) "*"
|
||||
}
|
||||
},
|
||||
|
||||
%attribute dictionary "times" {
|
||||
%attribute number "begin",
|
||||
%attribute number "end",
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -240,7 +250,13 @@ type Service {
|
|||
},
|
||||
%attribute array "groups" {
|
||||
%attribute name(UserGroup) "*"
|
||||
}
|
||||
},
|
||||
|
||||
%attribute dictionary "times" {
|
||||
%attribute number "begin",
|
||||
%attribute number "end",
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,6 +293,11 @@ type Notification {
|
|||
%attribute name(UserGroup) "*"
|
||||
},
|
||||
|
||||
%attribute dictionary "times" {
|
||||
%attribute number "begin",
|
||||
%attribute number "end",
|
||||
},
|
||||
|
||||
%attribute array "notification_command" {
|
||||
%attribute string "*"
|
||||
},
|
||||
|
|
|
@ -43,6 +43,7 @@ Notification::Notification(const Dictionary::Ptr& serializedUpdate)
|
|||
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);
|
||||
|
@ -132,6 +133,11 @@ std::set<UserGroup::Ptr> Notification::GetGroups(void) const
|
|||
return result;
|
||||
}
|
||||
|
||||
Dictionary::Ptr Notification::GetTimes(void) const
|
||||
{
|
||||
return m_Times;
|
||||
}
|
||||
|
||||
double Notification::GetNotificationInterval(void) const
|
||||
{
|
||||
if (m_NotificationInterval.IsEmpty())
|
||||
|
@ -202,17 +208,31 @@ String Notification::NotificationTypeToString(NotificationType type)
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -233,7 +253,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
|
|||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
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);
|
||||
|
@ -78,7 +79,7 @@ public:
|
|||
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);
|
||||
|
||||
|
@ -97,10 +98,11 @@ private:
|
|||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue