"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/notification/notificationcomponent.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

notificationcomponent.cpp  (icinga2-2.11.5):notificationcomponent.cpp  (icinga2-2.12.0)
skipping to change at line 59 skipping to change at line 59
} }
void NotificationComponent::Stop(bool runtimeRemoved) void NotificationComponent::Stop(bool runtimeRemoved)
{ {
Log(LogInformation, "NotificationComponent") Log(LogInformation, "NotificationComponent")
<< "'" << GetName() << "' stopped."; << "'" << GetName() << "' stopped.";
ObjectImpl<NotificationComponent>::Stop(runtimeRemoved); ObjectImpl<NotificationComponent>::Stop(runtimeRemoved);
} }
static inline
void SubtractSuppressedNotificationTypes(const Notification::Ptr& notification,
int types)
{
ObjectLock olock (notification);
int suppressedTypesBefore (notification->GetSuppressedNotifications());
int suppressedTypesAfter (suppressedTypesBefore & ~types);
if (suppressedTypesAfter != suppressedTypesBefore) {
notification->SetSuppressedNotifications(suppressedTypesAfter);
}
}
static inline
void FireSuppressedNotifications(const Notification::Ptr& notification)
{
int suppressedTypes (notification->GetSuppressedNotifications());
if (!suppressedTypes)
return;
int subtract = 0;
auto checkable (notification->GetCheckable());
for (auto type : {NotificationProblem, NotificationRecovery, Notification
FlappingStart, NotificationFlappingEnd}) {
if ((suppressedTypes & type) && !checkable->NotificationReasonApp
lies(type)) {
subtract |= type;
suppressedTypes &= ~type;
}
}
if (suppressedTypes) {
auto tp (notification->GetPeriod());
if ((!tp || tp->IsInside(Utility::GetTime())) && !checkable->IsLi
kelyToBeCheckedSoon()) {
for (auto type : {NotificationProblem, NotificationRecove
ry, NotificationFlappingStart, NotificationFlappingEnd}) {
if (!(suppressedTypes & type))
continue;
auto notificationName (notification->GetName());
Log(LogNotice, "NotificationComponent")
<< "Attempting to re-send previously supp
ressed notification '" << notificationName << "'.";
subtract |= type;
SubtractSuppressedNotificationTypes(notification,
subtract);
subtract = 0;
try {
notification->BeginExecuteNotification(ty
pe, checkable->GetLastCheckResult(), false, false);
} catch (const std::exception& ex) {
Log(LogWarning, "NotificationComponent")
<< "Exception occurred during not
ification for object '"
<< notificationName << "': " << D
iagnosticInformation(ex, false);
}
}
}
}
if (subtract) {
SubtractSuppressedNotificationTypes(notification, subtract);
}
}
/** /**
* Periodically sends notifications. * Periodically sends notifications.
* *
* @param - Event arguments for the timer. * @param - Event arguments for the timer.
*/ */
void NotificationComponent::NotificationTimerHandler() void NotificationComponent::NotificationTimerHandler()
{ {
double now = Utility::GetTime(); double now = Utility::GetTime();
/* Function already checks whether 'api' feature is enabled. */ /* Function already checks whether 'api' feature is enabled. */
skipping to change at line 107 skipping to change at line 170
} }
Checkable::Ptr checkable = notification->GetCheckable(); Checkable::Ptr checkable = notification->GetCheckable();
if (!IcingaApplication::GetInstance()->GetEnableNotifications() | | !checkable->GetEnableNotifications()) if (!IcingaApplication::GetInstance()->GetEnableNotifications() | | !checkable->GetEnableNotifications())
continue; continue;
bool reachable = checkable->IsReachable(DependencyNotification); bool reachable = checkable->IsReachable(DependencyNotification);
if (reachable) { if (reachable) {
Array::Ptr unstashedNotifications = new Array();
{ {
auto stashedNotifications (notification->GetStash Array::Ptr unstashedNotifications = new Array();
edNotifications());
ObjectLock olock(stashedNotifications);
stashedNotifications->CopyTo(unstashedNotificatio {
ns); auto stashedNotifications (notification->
stashedNotifications->Clear(); GetStashedNotifications());
} ObjectLock olock(stashedNotifications);
ObjectLock olock(unstashedNotifications); stashedNotifications->CopyTo(unstashedNot
ifications);
stashedNotifications->Clear();
}
for (Dictionary::Ptr unstashedNotification : unstashedNot ObjectLock olock(unstashedNotifications);
ifications) {
try {
Log(LogNotice, "NotificationComponent")
<< "Attempting to send stashed no
tification '" << notificationName << "'.";
notification->BeginExecuteNotification( for (Dictionary::Ptr unstashedNotification : unst
(NotificationType)(int)unstashedN ashedNotifications) {
otification->Get("type"), try {
(CheckResult::Ptr)unstashedNotifi Log(LogNotice, "NotificationCompo
cation->Get("cr"), nent")
(bool)unstashedNotification->Get( << "Attempting to send st
"force"), ashed notification '" << notificationName << "'.";
(bool)unstashedNotification->Get(
"reminder"), notification->BeginExecuteNotific
(String)unstashedNotification->Ge ation(
t("author"), (NotificationType)(int)un
(String)unstashedNotification->Ge stashedNotification->Get("type"),
t("text") (CheckResult::Ptr)unstash
); edNotification->Get("cr"),
} catch (const std::exception& ex) { (bool)unstashedNotificati
Log(LogWarning, "NotificationComponent") on->Get("force"),
<< "Exception occurred during not (bool)unstashedNotificati
ification for object '" on->Get("reminder"),
<< notificationName << "': " << D (String)unstashedNotifica
iagnosticInformation(ex, false); tion->Get("author"),
(String)unstashedNotifica
tion->Get("text")
);
} catch (const std::exception& ex) {
Log(LogWarning, "NotificationComp
onent")
<< "Exception occurred du
ring notification for object '"
<< notificationName << "'
: " << DiagnosticInformation(ex, false);
}
} }
} }
FireSuppressedNotifications(notification);
} }
if (notification->GetInterval() <= 0 && notification->GetNoMoreNo tifications()) { if (notification->GetInterval() <= 0 && notification->GetNoMoreNo tifications()) {
Log(LogNotice, "NotificationComponent") Log(LogNotice, "NotificationComponent")
<< "Reminder notification '" << notificationName << "': Notification was sent out once and interval=0 disables reminder notificat ions."; << "Reminder notification '" << notificationName << "': Notification was sent out once and interval=0 disables reminder notificat ions.";
continue; continue;
} }
if (notification->GetNextNotification() > now) if (notification->GetNextNotification() > now)
continue; continue;
 End of changes. 8 change blocks. 
36 lines changed or deleted 116 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)