@@ -129,34 +129,34 @@ void Checkable::UnregisterNotification(const Notification::Ptr& notification)
129
129
m_Notifications.erase (notification);
130
130
}
131
131
132
- static void FireSuppressedNotifications (Checkable* checkable )
132
+ void Checkable:: FireSuppressedNotifications ()
133
133
{
134
- if (!checkable-> IsActive ())
134
+ if (!IsActive ())
135
135
return ;
136
136
137
- if (checkable-> IsPaused ())
137
+ if (IsPaused ())
138
138
return ;
139
139
140
- if (!checkable-> GetEnableNotifications ())
140
+ if (!GetEnableNotifications ())
141
141
return ;
142
142
143
- int suppressed_types (checkable-> GetSuppressedNotifications ());
143
+ int suppressed_types (GetSuppressedNotifications ());
144
144
if (!suppressed_types)
145
145
return ;
146
146
147
147
int subtract = 0 ;
148
148
149
149
{
150
- LazyInit<bool > wasLastParentRecoveryRecent ([&checkable ]() {
151
- auto cr (checkable-> GetLastCheckResult ());
150
+ LazyInit<bool > wasLastParentRecoveryRecent ([this ]() {
151
+ auto cr (GetLastCheckResult ());
152
152
153
153
if (!cr) {
154
154
return true ;
155
155
}
156
156
157
157
auto threshold (cr->GetExecutionStart ());
158
158
159
- for (auto & dep : checkable-> GetDependencies ()) {
159
+ for (auto & dep : GetDependencies ()) {
160
160
auto parent (dep->GetParent ());
161
161
ObjectLock oLock (parent);
162
162
@@ -169,9 +169,9 @@ static void FireSuppressedNotifications(Checkable* checkable)
169
169
});
170
170
171
171
if (suppressed_types & (NotificationProblem|NotificationRecovery)) {
172
- CheckResult::Ptr cr = checkable-> GetLastCheckResult ();
173
- NotificationType type = cr && checkable-> IsStateOK (cr->GetState ()) ? NotificationRecovery : NotificationProblem;
174
- bool state_suppressed = checkable-> NotificationReasonSuppressed (NotificationProblem) || checkable-> NotificationReasonSuppressed (NotificationRecovery);
172
+ CheckResult::Ptr cr = GetLastCheckResult ();
173
+ NotificationType type = cr && IsStateOK (cr->GetState ()) ? NotificationRecovery : NotificationProblem;
174
+ bool state_suppressed = NotificationReasonSuppressed (NotificationProblem) || NotificationReasonSuppressed (NotificationRecovery);
175
175
176
176
/* Only process (i.e. send or dismiss) suppressed state notifications if the following conditions are met:
177
177
*
@@ -191,21 +191,21 @@ static void FireSuppressedNotifications(Checkable* checkable)
191
191
*
192
192
* If any of these conditions is not met, processing the suppressed notification is further delayed.
193
193
*/
194
- if (!state_suppressed && checkable-> GetStateType () == StateTypeHard && !checkable-> IsLikelyToBeCheckedSoon () && !wasLastParentRecoveryRecent.Get ()) {
195
- if (checkable-> NotificationReasonApplies (type)) {
196
- Checkable::OnNotificationsRequested (checkable , type, cr, " " , " " , nullptr );
194
+ if (!state_suppressed && GetStateType () == StateTypeHard && !IsLikelyToBeCheckedSoon () && !wasLastParentRecoveryRecent.Get ()) {
195
+ if (NotificationReasonApplies (type)) {
196
+ Checkable::OnNotificationsRequested (this , type, cr, " " , " " , nullptr );
197
197
}
198
198
subtract |= NotificationRecovery|NotificationProblem;
199
199
}
200
200
}
201
201
202
202
for (auto type : {NotificationFlappingStart, NotificationFlappingEnd}) {
203
203
if (suppressed_types & type) {
204
- bool still_applies = checkable-> NotificationReasonApplies (type);
204
+ bool still_applies = NotificationReasonApplies (type);
205
205
206
206
if (still_applies) {
207
- if (!checkable-> NotificationReasonSuppressed (type) && !checkable-> IsLikelyToBeCheckedSoon () && !wasLastParentRecoveryRecent.Get ()) {
208
- Checkable::OnNotificationsRequested (checkable , type, checkable-> GetLastCheckResult (), " " , " " , nullptr );
207
+ if (!NotificationReasonSuppressed (type) && !IsLikelyToBeCheckedSoon () && !wasLastParentRecoveryRecent.Get ()) {
208
+ Checkable::OnNotificationsRequested (this , type, GetLastCheckResult (), " " , " " , nullptr );
209
209
210
210
subtract |= type;
211
211
}
@@ -217,28 +217,28 @@ static void FireSuppressedNotifications(Checkable* checkable)
217
217
}
218
218
219
219
if (subtract) {
220
- ObjectLock olock (checkable );
220
+ ObjectLock olock (this );
221
221
222
- int suppressed_types_before (checkable-> GetSuppressedNotifications ());
222
+ int suppressed_types_before (GetSuppressedNotifications ());
223
223
int suppressed_types_after (suppressed_types_before & ~subtract);
224
224
225
225
if (suppressed_types_after != suppressed_types_before) {
226
- checkable-> SetSuppressedNotifications (suppressed_types_after);
226
+ SetSuppressedNotifications (suppressed_types_after);
227
227
}
228
228
}
229
229
}
230
230
231
231
/* *
232
232
* Re-sends all notifications previously suppressed by e.g. downtimes if the notification reason still applies.
233
233
*/
234
- void Checkable::FireSuppressedNotifications (const Timer * const &)
234
+ void Checkable::FireSuppressedNotificationsTimer (const Timer * const &)
235
235
{
236
236
for (auto & host : ConfigType::GetObjectsByType<Host>()) {
237
- :: FireSuppressedNotifications (host.get() );
237
+ host-> FireSuppressedNotifications ();
238
238
}
239
239
240
240
for (auto & service : ConfigType::GetObjectsByType<Service>()) {
241
- :: FireSuppressedNotifications (service.get() );
241
+ service-> FireSuppressedNotifications ();
242
242
}
243
243
}
244
244
0 commit comments