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

Method FlappingChangedHandler

lib/compat/compatlogger.cpp:313–352  ·  view source on GitHub ↗

* @threadsafety Always. */

Source from the content-addressed store, hash-verified

311 * @threadsafety Always.
312 */
313void CompatLogger::FlappingChangedHandler(const Checkable::Ptr& checkable)
314{
315 Host::Ptr host;
316 Service::Ptr service;
317 tie(host, service) = GetHostService(checkable);
318
319 String flapping_state_str;
320 String flapping_output;
321
322 if (checkable->IsFlapping()) {
323 flapping_output = "Checkable appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThresholdHigh()) + "% threshold)";
324 flapping_state_str = "STARTED";
325 } else {
326 flapping_output = "Checkable appears to have stopped flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change < " + Convert::ToString(checkable->GetFlappingThresholdLow()) + "% threshold)";
327 flapping_state_str = "STOPPED";
328 }
329
330 std::ostringstream msgbuf;
331
332 if (service) {
333 msgbuf << "SERVICE FLAPPING ALERT: "
334 << host->GetName() << ";"
335 << service->GetShortName() << ";"
336 << flapping_state_str << "; "
337 << flapping_output
338 << "";
339 } else {
340 msgbuf << "HOST FLAPPING ALERT: "
341 << host->GetName() << ";"
342 << flapping_state_str << "; "
343 << flapping_output
344 << "";
345 }
346
347 {
348 ObjectLock oLock(this);
349 WriteLine(msgbuf.str());
350 Flush();
351 }
352}
353
354void CompatLogger::EnableFlappingChangedHandler(const Checkable::Ptr& checkable)
355{

Callers

nothing calls this directly

Calls 2

IsFlappingMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected