From 88776a4be86b160fb0b3c97a41eeb7e5e6a922e9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 3 Aug 2012 14:07:25 +0200 Subject: [PATCH] Fixed task statistics. --- cib/Makefile.am | 7 ++- cib/checkresult.h | 43 ------------------- cib/i2-cib.h | 3 +- ...sage.cpp => servicestatechangemessage.cpp} | 4 +- ...tmessage.h => servicestatechangemessage.h} | 12 +++--- components/checker/checkercomponent.cpp | 4 +- components/cibsync/cibsynccomponent.cpp | 10 ++--- components/cibsync/cibsynccomponent.h | 2 +- 8 files changed, 20 insertions(+), 65 deletions(-) delete mode 100644 cib/checkresult.h rename cib/{checkresultmessage.cpp => servicestatechangemessage.cpp} (92%) rename cib/{checkresultmessage.h => servicestatechangemessage.h} (83%) diff --git a/cib/Makefile.am b/cib/Makefile.am index e2d5610fe..98cfdf6bf 100644 --- a/cib/Makefile.am +++ b/cib/Makefile.am @@ -4,9 +4,6 @@ pkglib_LTLIBRARIES = \ libcib.la libcib_la_SOURCES = \ - checkresult.h \ - checkresultmessage.cpp \ - checkresultmessage.h \ cib.cpp \ cib.h \ host.cpp \ @@ -23,7 +20,9 @@ libcib_la_SOURCES = \ service.cpp \ service.h \ servicegroup.cpp \ - servicegroup.h + servicegroup.h \ + servicestatechangemessage.cpp \ + servicestatechangemessage.h libcib_la_CPPFLAGS = \ -DI2_CIB_BUILD \ diff --git a/cib/checkresult.h b/cib/checkresult.h deleted file mode 100644 index 3c0698b95..000000000 --- a/cib/checkresult.h +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#ifndef CHECKRESULT_H -#define CHECKRESULT_H - -namespace icinga -{ - -/*struct CheckResult -{ - static const char *ScheduleStart = "schedule_start"; - static const char *ScheduleEnd = "schedule_end"; - static const char *ExecutionStart = "execution_start"; - static const char *ExecutionEnd = "execution_end"; - static const char *State = "state"; - static const char *Output = "output"; - static const char *PerformanceDataRaw = "performance_data_raw"; - static const char *PerformanceData = "performance_data"; - -private: - CheckResult(); -};*/ - -} - -#endif /* CHECKRESULT_H */ diff --git a/cib/i2-cib.h b/cib/i2-cib.h index 2964f10b0..9863164d4 100644 --- a/cib/i2-cib.h +++ b/cib/i2-cib.h @@ -42,11 +42,10 @@ #include "servicegroup.h" #include "macroprocessor.h" -#include "checkresult.h" #include "nagioschecktask.h" #include "nullchecktask.h" -#include "checkresultmessage.h" +#include "servicestatechangemessage.h" #include "cib.h" diff --git a/cib/checkresultmessage.cpp b/cib/servicestatechangemessage.cpp similarity index 92% rename from cib/checkresultmessage.cpp rename to cib/servicestatechangemessage.cpp index 35078c30d..030e893f8 100644 --- a/cib/checkresultmessage.cpp +++ b/cib/servicestatechangemessage.cpp @@ -21,12 +21,12 @@ using namespace icinga; -bool CheckResultMessage::GetService(String *service) const +bool ServiceStateChangeMessage::GetService(String *service) const { return Get("service", service); } -void CheckResultMessage::SetService(const String& service) +void ServiceStateChangeMessage::SetService(const String& service) { Set("service", service); } diff --git a/cib/checkresultmessage.h b/cib/servicestatechangemessage.h similarity index 83% rename from cib/checkresultmessage.h rename to cib/servicestatechangemessage.h index 5e37bf05b..bee5082cc 100644 --- a/cib/checkresultmessage.h +++ b/cib/servicestatechangemessage.h @@ -17,17 +17,17 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#ifndef CHECKRESULTMESSAGE_H -#define CHECKRESULTMESSAGE_H +#ifndef SERVICESTATECHANGEMESSAGE_H +#define SERVICESTATECHANGEMESSAGE_H namespace icinga { -class I2_CIB_API CheckResultMessage : public MessagePart +class I2_CIB_API ServiceStateChangeMessage : public MessagePart { public: - CheckResultMessage(void) : MessagePart() { } - CheckResultMessage(const MessagePart& message) : MessagePart(message) { } + ServiceStateChangeMessage(void) : MessagePart() { } + ServiceStateChangeMessage(const MessagePart& message) : MessagePart(message) { } bool GetService(String *service) const; void SetService(const String& service); @@ -35,4 +35,4 @@ public: } -#endif /* CHECKRESULTMESSAGE_H */ +#endif /* SERVICESTATECHANGEMESSAGE_H */ diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index c67ea518e..992d84bf6 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -28,7 +28,7 @@ void CheckerComponent::Start(void) boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _2, _3)); m_Endpoint->RegisterTopicHandler("checker::ClearServices", boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _2, _3)); - m_Endpoint->RegisterPublication("checker::CheckResult"); + m_Endpoint->RegisterPublication("checker::ServiceStateChange"); EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint); m_CheckTimer = boost::make_shared(); @@ -106,7 +106,7 @@ void CheckerComponent::CheckCompletedHandler(const Service::Ptr& service, const rm.SetMethod("checker::ServiceStateChange"); /* TODO: add _old_ state to message */ - CheckResultMessage params; + ServiceStateChangeMessage params; params.SetService(service->GetName()); rm.SetParams(params); diff --git a/components/cibsync/cibsynccomponent.cpp b/components/cibsync/cibsynccomponent.cpp index 71de26a83..9b1264a3a 100644 --- a/components/cibsync/cibsynccomponent.cpp +++ b/components/cibsync/cibsynccomponent.cpp @@ -50,8 +50,8 @@ void CIBSyncComponent::Start(void) boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3)); /* service status */ - m_Endpoint->RegisterTopicHandler("checker::CheckResult", - boost::bind(&CIBSyncComponent::CheckResultRequestHandler, _2, _3)); + m_Endpoint->RegisterTopicHandler("checker::ServiceStateChange", + boost::bind(&CIBSyncComponent::ServiceStateChangeRequestHandler, _2, _3)); EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint); } @@ -67,9 +67,9 @@ void CIBSyncComponent::Stop(void) endpointManager->UnregisterEndpoint(m_Endpoint); } -void CIBSyncComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request) +void CIBSyncComponent::ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request) { - CheckResultMessage params; + ServiceStateChangeMessage params; if (!request.GetParams(¶ms)) return; @@ -179,7 +179,7 @@ void CIBSyncComponent::TransactionClosingHandler(const set& stringstream msgbuf; msgbuf << "Sending " << modifiedObjects.size() << " replication updates."; - Logger::Write(LogInformation, "cibsync", msgbuf.str()); + Logger::Write(LogDebug, "cibsync", msgbuf.str()); BOOST_FOREACH(const DynamicObject::Ptr& object, modifiedObjects) { if (!ShouldReplicateObject(object)) diff --git a/components/cibsync/cibsynccomponent.h b/components/cibsync/cibsynccomponent.h index f912e4de3..7188fef12 100644 --- a/components/cibsync/cibsynccomponent.h +++ b/components/cibsync/cibsynccomponent.h @@ -36,7 +36,7 @@ private: VirtualEndpoint::Ptr m_Endpoint; bool m_SyncingConfig; - static void CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); + static void ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); void NewEndpointHandler(const Endpoint::Ptr& endpoint); void SessionEstablishedHandler(const Endpoint::Ptr& endpoint); -- 2.40.0