| 286 | } |
| 287 | |
| 288 | void 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 | |
| 327 | void 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) |
nothing calls this directly
no test coverage detected