MCPcopy Create free account
hub / github.com/Icinga/icinga2 / StateChangeHandler

Method StateChangeHandler

lib/perfdata/elasticsearchwriter.cpp:288–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void ElasticsearchWriter::StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
289{
290 if (IsPaused())
291 return;
292
293 Host::Ptr host;
294 Service::Ptr service;
295 tie(host, service) = GetHostService(checkable);
296
297 Dictionary::Ptr fields = new Dictionary();
298
299 fields->Set("current_check_attempt", checkable->GetCheckAttempt());
300 fields->Set("max_check_attempts", checkable->GetMaxCheckAttempts());
301 fields->Set("host", host->GetName());
302
303 if (service) {
304 fields->Set("service", service->GetShortName());
305 fields->Set("state", service->GetState());
306 fields->Set("last_state", service->GetLastState());
307 fields->Set("last_hard_state", service->GetLastHardState());
308 } else {
309 fields->Set("state", host->GetState());
310 fields->Set("last_state", host->GetLastState());
311 fields->Set("last_hard_state", host->GetLastHardState());
312 }
313
314 fields->Set("check_command", checkable->GetCheckCommand()->GetName());
315
316 AddTemplateTags(fields, checkable, cr);
317
318 m_WorkQueue.Enqueue([this, checkable, cr, fields = std::move(fields)]() {
319 CONTEXT("Elasticwriter processing state change '" << checkable->GetName() << "'");
320
321 AddCheckResult(fields, checkable, cr);
322
323 Enqueue(checkable, "statechange", fields, cr->GetExecutionEnd());
324 });
325}
326
327void ElasticsearchWriter::NotificationSentToAllUsersHandler(const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
328 NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text)

Callers

nothing calls this directly

Calls 7

GetLastStateMethod · 0.80
GetLastHardStateMethod · 0.80
GetCheckCommandMethod · 0.80
SetMethod · 0.45
GetNameMethod · 0.45
GetStateMethod · 0.45
EnqueueMethod · 0.45

Tested by

no test coverage detected