"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/icinga/checkable-notification.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.

checkable-notification.cpp  (icinga2-2.11.5):checkable-notification.cpp  (icinga2-2.12.0)
skipping to change at line 150 skipping to change at line 150
return; return;
int suppressed_types (checkable->GetSuppressedNotifications()); int suppressed_types (checkable->GetSuppressedNotifications());
if (!suppressed_types) if (!suppressed_types)
return; return;
int subtract = 0; int subtract = 0;
for (auto type : {NotificationProblem, NotificationRecovery, Notification FlappingStart, NotificationFlappingEnd}) { for (auto type : {NotificationProblem, NotificationRecovery, Notification FlappingStart, NotificationFlappingEnd}) {
if (suppressed_types & type) { if (suppressed_types & type) {
bool still_applies; bool still_applies = checkable->NotificationReasonApplies
auto cr (checkable->GetLastCheckResult()); (type);
switch (type) {
case NotificationProblem:
still_applies = cr && !checkable->IsState
OK(cr->GetState()) && checkable->GetStateType() == StateTypeHard;
break;
case NotificationRecovery:
still_applies = cr && checkable->IsStateO
K(cr->GetState());
break;
case NotificationFlappingStart:
still_applies = checkable->IsFlapping();
break;
case NotificationFlappingEnd:
still_applies = !checkable->IsFlapping();
break;
default:
break;
}
if (still_applies) { if (still_applies) {
bool still_suppressed; bool still_suppressed;
switch (type) { switch (type) {
case NotificationProblem: case NotificationProblem:
/* Fall through. */ /* Fall through. */
case NotificationRecovery: case NotificationRecovery:
still_suppressed = !checkable->Is Reachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsA cknowledged(); still_suppressed = !checkable->Is Reachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsA cknowledged();
break; break;
case NotificationFlappingStart: case NotificationFlappingStart:
/* Fall through. */ /* Fall through. */
case NotificationFlappingEnd: case NotificationFlappingEnd:
still_suppressed = checkable->IsI nDowntime(); still_suppressed = checkable->IsI nDowntime();
break; break;
default: default:
break; break;
} }
if (!still_suppressed && checkable->GetEnableActi if (!still_suppressed && !checkable->IsLikelyToBe
veChecks()) { CheckedSoon()) {
/* If e.g. the downtime just ended, but t Checkable::OnNotificationsRequested(check
he service is still not ok, we would re-send the stashed problem notification. able, type, checkable->GetLastCheckResult(), "", "", nullptr);
* But if the next check result recovers
the service soon, we would send a recovery notification soon after the problem o
ne.
* This is not desired, especially for lo
ts of services at once.
* Because of that if there's likely to b
e a check result soon,
* we delay the re-sending of the stashed
notification until the next check.
* That check either doesn't change anyth
ing and we finally re-send the stashed problem notification
* or recovers the service and we drop th
e stashed notification. */
/* One minute unless the check interval i
s too short so the next check will always run during the next minute. */
auto threshold (checkable->GetCheckInterv
al() - 10);
if (threshold > 60)
threshold = 60;
else if (threshold < 0)
threshold = 0;
still_suppressed = checkable->GetNextChec
k() <= Utility::GetTime() + threshold;
}
if (!still_suppressed) {
Checkable::OnNotificationsRequested(check
able, type, cr, "", "", nullptr);
subtract |= type; subtract |= type;
} }
} else { } else {
subtract |= type; subtract |= type;
} }
} }
} }
if (subtract) { if (subtract) {
skipping to change at line 244 skipping to change at line 206
void Checkable::FireSuppressedNotifications(const Timer * const&) void Checkable::FireSuppressedNotifications(const Timer * const&)
{ {
for (auto& host : ConfigType::GetObjectsByType<Host>()) { for (auto& host : ConfigType::GetObjectsByType<Host>()) {
::FireSuppressedNotifications(host.get()); ::FireSuppressedNotifications(host.get());
} }
for (auto& service : ConfigType::GetObjectsByType<Service>()) { for (auto& service : ConfigType::GetObjectsByType<Service>()) {
::FireSuppressedNotifications(service.get()); ::FireSuppressedNotifications(service.get());
} }
} }
/**
* Returns whether sending a notification of type type right now would represent
*this' current state correctly.
*
* @param type The type of notification to send (or not to send).
*
* @return Whether to send the notification.
*/
bool Checkable::NotificationReasonApplies(NotificationType type)
{
switch (type) {
case NotificationProblem:
{
auto cr (GetLastCheckResult());
return cr && !IsStateOK(cr->GetState()) && GetSta
teType() == StateTypeHard;
}
case NotificationRecovery:
{
auto cr (GetLastCheckResult());
return cr && IsStateOK(cr->GetState());
}
case NotificationFlappingStart:
return IsFlapping();
case NotificationFlappingEnd:
return !IsFlapping();
default:
VERIFY(!"Checkable#NotificationReasonStillApplies(): give
n type not implemented");
return false;
}
}
/**
* E.g. we're going to re-send a stashed problem notification as *this is still
not ok.
* But if the next check result recovers *this soon, we would send a recovery no
tification soon after the problem one.
* This is not desired, especially for lots of checkables at once.
* Because of that if there's likely to be a check result soon,
* we delay the re-sending of the stashed notification until the next check.
* That check either doesn't change anything and we finally re-send the stashed
problem notification
* or recovers *this and we drop the stashed notification.
*
* @return Whether *this is likely to be checked soon
*/
bool Checkable::IsLikelyToBeCheckedSoon()
{
if (!GetEnableActiveChecks()) {
return false;
}
// One minute unless the check interval is too short so the next check wi
ll always run during the next minute.
auto threshold (GetCheckInterval() - 10);
if (threshold > 60) {
threshold = 60;
} else if (threshold < 0) {
threshold = 0;
}
return GetNextCheck() <= Utility::GetTime() + threshold;
}
 End of changes. 3 change blocks. 
56 lines changed or deleted 6 lines changed or added

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