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

Method SuppressedNotificationsChangedAPIHandler

lib/icinga/clusterevents.cpp:403–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403Value ClusterEvents::SuppressedNotificationsChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
404{
405 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
406
407 if (!endpoint) {
408 Log(LogNotice, "ClusterEvents")
409 << "Discarding 'suppressed notifications changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
410 return Empty;
411 }
412
413 Host::Ptr host = Host::GetByName(params->Get("host"));
414
415 if (!host)
416 return Empty;
417
418 Checkable::Ptr checkable;
419
420 if (params->Contains("service"))
421 checkable = host->GetServiceByShortName(params->Get("service"));
422 else
423 checkable = host;
424
425 if (!checkable)
426 return Empty;
427
428 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
429 Log(LogNotice, "ClusterEvents")
430 << "Discarding 'suppressed notifications changed' message for checkable '" << checkable->GetName()
431 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
432 return Empty;
433 }
434
435 checkable->SetSuppressedNotifications(params->Get("suppressed_notifications"), false, origin);
436
437 return Empty;
438}
439
440void ClusterEvents::SuppressedNotificationTypesChangedHandler(const Notification::Ptr& notification, const MessageOrigin::Ptr& origin)
441{

Callers

nothing calls this directly

Calls 7

LogClass · 0.85
GetEndpointMethod · 0.80
GetIdentityMethod · 0.80
GetServiceByShortNameMethod · 0.80
GetMethod · 0.45
ContainsMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected