From 48ec2dfd082e25b1f39ea824278afeb630d774a5 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 17 Sep 2013 14:58:52 +0200 Subject: [PATCH] cluster: Log ignored messages. --- components/cluster/clustercomponent.cpp | 107 ++++++++++++++++++++---- 1 file changed, 92 insertions(+), 15 deletions(-) diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp index 2027afad7..fc496487b 100644 --- a/components/cluster/clustercomponent.cpp +++ b/components/cluster/clustercomponent.cpp @@ -1022,9 +1022,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + Dictionary::Ptr cr = params->Get("check_result"); if (!cr) @@ -1041,9 +1046,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + double nextCheck = params->Get("next_check"); service->SetNextCheck(nextCheck, sender->GetName()); @@ -1057,9 +1067,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool forced = params->Get("forced"); service->SetForceNextCheck(forced, sender->GetName()); @@ -1073,9 +1088,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool forced = params->Get("forced"); service->SetForceNextNotification(forced, sender->GetName()); @@ -1089,9 +1109,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool enabled = params->Get("enabled"); service->SetEnableActiveChecks(enabled, sender->GetName()); @@ -1105,9 +1130,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool enabled = params->Get("enabled"); service->SetEnablePassiveChecks(enabled, sender->GetName()); @@ -1121,9 +1151,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool enabled = params->Get("enabled"); service->SetEnableNotifications(enabled, sender->GetName()); @@ -1137,9 +1172,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool enabled = params->Get("enabled"); service->SetEnableFlapping(enabled, sender->GetName()); @@ -1153,9 +1193,16 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Notification::Ptr notification = Notification::GetByName(nfc); - if (!notification || !notification->GetService()->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!notification) return; + Service::Ptr service = notification->GetService(); + + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + bool nextNotification = params->Get("next_notification"); notification->SetNextNotification(nextNotification, sender->GetName()); @@ -1169,9 +1216,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + Dictionary::Ptr comment = params->Get("comment"); long type = static_cast(comment->Get("entry_type")); @@ -1187,9 +1239,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + String id = params->Get("id"); service->RemoveComment(id, sender->GetName()); @@ -1203,9 +1260,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + Dictionary::Ptr downtime = params->Get("downtime"); service->AddDowntime(downtime->Get("comment_id"), @@ -1222,9 +1284,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + String id = params->Get("id"); service->RemoveDowntime(id, sender->GetName()); @@ -1238,9 +1305,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + String author = params->Get("author"); String comment = params->Get("comment"); int type = params->Get("type"); @@ -1257,9 +1329,14 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction Service::Ptr service = Service::GetByName(svc); - if (!service || !service->HasPrivileges(sender->GetName(), DomainPrivCommand)) + if (!service) return; + if (!service->HasPrivileges(sender->GetName(), DomainPrivCommand)) { + Log(LogDebug, "cluster", "Not accepting message from endpoint '" + sender->GetName() + "' for service '" + service->GetName() + "': Insufficient privileges."); + return; + } + { ObjectLock olock(service); service->ClearAcknowledgement(sender->GetName());