From f2420fb17a8769b5bf28a27c680c2f8f6cf4c584 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 2 Jul 2012 12:34:54 +0200 Subject: [PATCH] Moved CIB stuff into a separate library and loadable component. --- Makefile.am | 2 +- cib/Makefile.am | 47 ++++++++ {icinga => cib}/checkresult.cpp | 2 +- {icinga => cib}/checkresult.h | 0 {icinga => cib}/checktask.cpp | 2 +- {icinga => cib}/checktask.h | 0 cib/cib.cpp | 35 ++++++ {icinga => cib}/cib.h | 7 +- {icinga => cib}/configobjectadapter.cpp | 2 +- {icinga => cib}/configobjectadapter.h | 0 {icinga => cib}/host.cpp | 2 +- {icinga => cib}/host.h | 0 {icinga => cib}/hostgroup.cpp | 2 +- {icinga => cib}/hostgroup.h | 0 cib/i2-cib.h | 32 ++++++ {icinga => cib}/macroprocessor.cpp | 2 +- {icinga => cib}/macroprocessor.h | 0 {icinga => cib}/nagioschecktask.cpp | 2 +- {icinga => cib}/nagioschecktask.h | 0 {icinga => cib}/service.cpp | 2 +- {icinga => cib}/service.h | 0 {icinga => cib}/servicegroup.cpp | 2 +- {icinga => cib}/servicegroup.h | 0 components/Makefile.am | 1 + components/checker/Makefile.am | 6 +- components/checker/i2-checker.h | 1 + components/cibsync/Makefile.am | 29 +++++ components/cibsync/cibsynccomponent.cpp | 105 ++++++++++++++++++ components/cibsync/cibsynccomponent.h | 44 ++++++++ components/cibsync/i2-cibsync.h | 36 ++++++ components/compat/Makefile.am | 6 +- components/compat/i2-compat.h | 1 + components/delegation/Makefile.am | 6 +- components/delegation/delegationcomponent.cpp | 2 + components/delegation/i2-delegation.h | 1 + components/discovery/Makefile.am | 6 +- components/discovery/discoverycomponent.cpp | 2 + components/discovery/i2-discovery.h | 1 + configure.ac | 3 +- dyntest/Makefile.am | 24 ---- dyntest/dyntest.cpp | 32 ------ dyntest/dyntest.vcxproj | 91 --------------- dyntest/dyntest.vcxproj.filters | 22 ---- icinga/Makefile.am | 24 +--- icinga/cib.cpp | 76 ------------- icinga/i2-icinga.h | 13 --- icinga/icingaapplication.cpp | 3 - 47 files changed, 368 insertions(+), 308 deletions(-) create mode 100644 cib/Makefile.am rename {icinga => cib}/checkresult.cpp (98%) rename {icinga => cib}/checkresult.h (100%) rename {icinga => cib}/checktask.cpp (98%) rename {icinga => cib}/checktask.h (100%) create mode 100644 cib/cib.cpp rename {icinga => cib}/cib.h (68%) rename {icinga => cib}/configobjectadapter.cpp (94%) rename {icinga => cib}/configobjectadapter.h (100%) rename {icinga => cib}/host.cpp (96%) rename {icinga => cib}/host.h (100%) rename {icinga => cib}/hostgroup.cpp (97%) rename {icinga => cib}/hostgroup.h (100%) create mode 100644 cib/i2-cib.h rename {icinga => cib}/macroprocessor.cpp (97%) rename {icinga => cib}/macroprocessor.h (100%) rename {icinga => cib}/nagioschecktask.cpp (99%) rename {icinga => cib}/nagioschecktask.h (100%) rename {icinga => cib}/service.cpp (99%) rename {icinga => cib}/service.h (100%) rename {icinga => cib}/servicegroup.cpp (97%) rename {icinga => cib}/servicegroup.h (100%) create mode 100644 components/cibsync/Makefile.am create mode 100644 components/cibsync/cibsynccomponent.cpp create mode 100644 components/cibsync/cibsynccomponent.h create mode 100644 components/cibsync/i2-cibsync.h delete mode 100644 dyntest/Makefile.am delete mode 100644 dyntest/dyntest.cpp delete mode 100644 dyntest/dyntest.vcxproj delete mode 100644 dyntest/dyntest.vcxproj.filters delete mode 100644 icinga/cib.cpp diff --git a/Makefile.am b/Makefile.am index 030f64b1e..4fec7325e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,8 +8,8 @@ SUBDIRS = \ base \ dyn \ jsonrpc \ - dyntest \ icinga \ + cib \ components \ icinga-app \ test diff --git a/cib/Makefile.am b/cib/Makefile.am new file mode 100644 index 000000000..f88026113 --- /dev/null +++ b/cib/Makefile.am @@ -0,0 +1,47 @@ +## Process this file with automake to produce Makefile.in + +pkglib_LTLIBRARIES = \ + libcib.la + +libcib_la_SOURCES = \ + checkresult.cpp \ + checkresult.h \ + checktask.cpp \ + checktask.h \ + cib.cpp \ + cib.h \ + configobjectadapter.cpp \ + configobjectadapter.h \ + host.cpp \ + host.h \ + hostgroup.cpp \ + hostgroup.h \ + i2-cib.h \ + macroprocessor.cpp \ + macroprocessor.h \ + nagioschecktask.cpp \ + nagioschecktask.h \ + service.cpp \ + service.h \ + servicegroup.cpp \ + servicegroup.h + +libcib_la_CPPFLAGS = \ + -DI2_CIB_BUILD \ + $(BOOST_CPPFLAGS) \ + -I${top_srcdir}/base \ + -I${top_srcdir}/jsonrpc \ + -I${top_srcdir}/icinga \ + -I${top_srcdir}/third-party/popen-noshell + +libcib_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ + -no-undefined \ + @RELEASE_INFO@ \ + @VERSION_INFO@ + +libcib_la_LIBADD = \ + ${top_builddir}/base/libbase.la \ + ${top_builddir}/jsonrpc/libjsonrpc.la \ + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/third-party/popen-noshell/libpopen_noshell.la diff --git a/icinga/checkresult.cpp b/cib/checkresult.cpp similarity index 98% rename from icinga/checkresult.cpp rename to cib/checkresult.cpp index 9377dd1a6..eca577546 100644 --- a/icinga/checkresult.cpp +++ b/cib/checkresult.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/checkresult.h b/cib/checkresult.h similarity index 100% rename from icinga/checkresult.h rename to cib/checkresult.h diff --git a/icinga/checktask.cpp b/cib/checktask.cpp similarity index 98% rename from icinga/checktask.cpp rename to cib/checktask.cpp index 1799b0490..5b5ac8410 100644 --- a/icinga/checktask.cpp +++ b/cib/checktask.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/checktask.h b/cib/checktask.h similarity index 100% rename from icinga/checktask.h rename to cib/checktask.h diff --git a/cib/cib.cpp b/cib/cib.cpp new file mode 100644 index 000000000..a562bc62c --- /dev/null +++ b/cib/cib.cpp @@ -0,0 +1,35 @@ +#include "i2-cib.h" + +using namespace icinga; + +int CIB::m_Types; +Ringbuffer CIB::m_TaskStatistics(15 * 60); + +void CIB::RequireInformation(InformationType types) +{ + m_Types |= types; + + Application::Ptr app = Application::GetInstance(); + Component::Ptr component = app->GetComponent("cibsync"); + + if (!component) { + ConfigObject::Ptr cibsyncComponentConfig = boost::make_shared("component", "cibsync"); + cibsyncComponentConfig->SetLocal(true); + cibsyncComponentConfig->Commit(); + } +} + +void CIB::UpdateTaskStatistics(long tv, int num) +{ + m_TaskStatistics.InsertValue(tv, num); +} + +int CIB::GetTaskStatistics(long timespan) +{ + return m_TaskStatistics.GetValues(timespan); +} + +int CIB::GetInformationTypes(void) +{ + return m_Types; +} diff --git a/icinga/cib.h b/cib/cib.h similarity index 68% rename from icinga/cib.h rename to cib/cib.h index c01a3f389..8bff7780e 100644 --- a/icinga/cib.h +++ b/cib/cib.h @@ -15,18 +15,15 @@ class CIB { public: static void RequireInformation(InformationType type); + static int GetInformationTypes(void); - static void Start(void); - + static void UpdateTaskStatistics(long tv, int num); static int GetTaskStatistics(long timespan); private: static int m_Types; - static VirtualEndpoint::Ptr m_Endpoint; static Ringbuffer m_TaskStatistics; - - static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); }; } diff --git a/icinga/configobjectadapter.cpp b/cib/configobjectadapter.cpp similarity index 94% rename from icinga/configobjectadapter.cpp rename to cib/configobjectadapter.cpp index 7da5cdf2b..a0f32e76f 100644 --- a/icinga/configobjectadapter.cpp +++ b/cib/configobjectadapter.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/configobjectadapter.h b/cib/configobjectadapter.h similarity index 100% rename from icinga/configobjectadapter.h rename to cib/configobjectadapter.h diff --git a/icinga/host.cpp b/cib/host.cpp similarity index 96% rename from icinga/host.cpp rename to cib/host.cpp index cfda2796a..c99dd15aa 100644 --- a/icinga/host.cpp +++ b/cib/host.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/host.h b/cib/host.h similarity index 100% rename from icinga/host.h rename to cib/host.h diff --git a/icinga/hostgroup.cpp b/cib/hostgroup.cpp similarity index 97% rename from icinga/hostgroup.cpp rename to cib/hostgroup.cpp index 903dfdd4e..6c8f2c398 100644 --- a/icinga/hostgroup.cpp +++ b/cib/hostgroup.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/hostgroup.h b/cib/hostgroup.h similarity index 100% rename from icinga/hostgroup.h rename to cib/hostgroup.h diff --git a/cib/i2-cib.h b/cib/i2-cib.h new file mode 100644 index 000000000..6a5d38250 --- /dev/null +++ b/cib/i2-cib.h @@ -0,0 +1,32 @@ +#ifndef I2CIB_H +#define I2CIB_H + +/** + * @defgroup cib Common Information Base + * + * The CIB component implements functionality to gather status + * updates from all the other Icinga components. + */ + +#include + +#ifdef I2_CIB_BUILD +# define I2_CIB_API I2_EXPORT +#else /* I2_CIB_BUILD */ +# define I2_CIB_API I2_IMPORT +#endif /* I2_CIB_BUILD */ + +#include "configobjectadapter.h" +#include "host.h" +#include "hostgroup.h" +#include "service.h" +#include "servicegroup.h" + +#include "cib.h" + +#include "macroprocessor.h" +#include "checkresult.h" +#include "checktask.h" +#include "nagioschecktask.h" + +#endif /* I2CIB_H */ diff --git a/icinga/macroprocessor.cpp b/cib/macroprocessor.cpp similarity index 97% rename from icinga/macroprocessor.cpp rename to cib/macroprocessor.cpp index 291161e78..7a699585f 100644 --- a/icinga/macroprocessor.cpp +++ b/cib/macroprocessor.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/macroprocessor.h b/cib/macroprocessor.h similarity index 100% rename from icinga/macroprocessor.h rename to cib/macroprocessor.h diff --git a/icinga/nagioschecktask.cpp b/cib/nagioschecktask.cpp similarity index 99% rename from icinga/nagioschecktask.cpp rename to cib/nagioschecktask.cpp index 30c3de97d..f9a0cbe8a 100644 --- a/icinga/nagioschecktask.cpp +++ b/cib/nagioschecktask.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" #ifndef _MSC_VER # include "popen_noshell.h" diff --git a/icinga/nagioschecktask.h b/cib/nagioschecktask.h similarity index 100% rename from icinga/nagioschecktask.h rename to cib/nagioschecktask.h diff --git a/icinga/service.cpp b/cib/service.cpp similarity index 99% rename from icinga/service.cpp rename to cib/service.cpp index 2c8621c17..60837c6c9 100644 --- a/icinga/service.cpp +++ b/cib/service.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/service.h b/cib/service.h similarity index 100% rename from icinga/service.h rename to cib/service.h diff --git a/icinga/servicegroup.cpp b/cib/servicegroup.cpp similarity index 97% rename from icinga/servicegroup.cpp rename to cib/servicegroup.cpp index 24496af4b..769f21081 100644 --- a/icinga/servicegroup.cpp +++ b/cib/servicegroup.cpp @@ -1,4 +1,4 @@ -#include "i2-icinga.h" +#include "i2-cib.h" using namespace icinga; diff --git a/icinga/servicegroup.h b/cib/servicegroup.h similarity index 100% rename from icinga/servicegroup.h rename to cib/servicegroup.h diff --git a/components/Makefile.am b/components/Makefile.am index 781a6f53f..d8211bb52 100644 --- a/components/Makefile.am +++ b/components/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = \ checker \ + cibsync \ compat \ configfile \ configrpc \ diff --git a/components/checker/Makefile.am b/components/checker/Makefile.am index 63f35d0af..d1d9cf63b 100644 --- a/components/checker/Makefile.am +++ b/components/checker/Makefile.am @@ -12,7 +12,8 @@ checker_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ - -I${top_srcdir}/icinga + -I${top_srcdir}/icinga \ + -I${top_srcdir}/cib checker_la_LDFLAGS = \ $(BOOST_LDFLAGS) \ @@ -24,4 +25,5 @@ checker_la_LDFLAGS = \ checker_la_LIBADD = \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ - ${top_builddir}/icinga/libicinga.la + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/cib/libcib.la diff --git a/components/checker/i2-checker.h b/components/checker/i2-checker.h index 8a0ad53de..b142c84d6 100644 --- a/components/checker/i2-checker.h +++ b/components/checker/i2-checker.h @@ -28,6 +28,7 @@ #include #include +#include #include diff --git a/components/cibsync/Makefile.am b/components/cibsync/Makefile.am new file mode 100644 index 000000000..7f677c27f --- /dev/null +++ b/components/cibsync/Makefile.am @@ -0,0 +1,29 @@ +## Process this file with automake to produce Makefile.in + +pkglib_LTLIBRARIES = \ + cibsync.la + +cibsync_la_SOURCES = \ + cibsynccomponent.cpp \ + cibsynccomponent.h \ + i2-cibsync.h + +cibsync_la_CPPFLAGS = \ + $(BOOST_CPPFLAGS) \ + -I${top_srcdir}/base \ + -I${top_srcdir}/jsonrpc \ + -I${top_srcdir}/icinga \ + -I${top_srcdir}/cib + +cibsync_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ + -module \ + -no-undefined \ + @RELEASE_INFO@ \ + @VERSION_INFO@ + +cibsync_la_LIBADD = \ + ${top_builddir}/base/libbase.la \ + ${top_builddir}/jsonrpc/libjsonrpc.la \ + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/cib/libcib.la diff --git a/components/cibsync/cibsynccomponent.cpp b/components/cibsync/cibsynccomponent.cpp new file mode 100644 index 000000000..a616fd360 --- /dev/null +++ b/components/cibsync/cibsynccomponent.cpp @@ -0,0 +1,105 @@ +/****************************************************************************** + * 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. * + ******************************************************************************/ + +#include "i2-cibsync.h" + +using namespace icinga; + +/** + * Returns the name of the component. + * + * @returns The name. + */ +string CIBSyncComponent::GetName(void) const +{ + return "cibsync"; +} + +/** + * Starts the component. + */ +void CIBSyncComponent::Start(void) +{ + m_Endpoint = boost::make_shared(); + m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus", + boost::bind(&CIBSyncComponent::ServiceStatusRequestHandler, _2, _3)); + EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint); +} + +/** + * Stops the component. + */ +void CIBSyncComponent::Stop(void) +{ + EndpointManager::Ptr endpointManager = EndpointManager::GetInstance(); + + if (endpointManager) + endpointManager->UnregisterEndpoint(m_Endpoint); +} + +void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request) +{ + MessagePart params; + if (!request.GetParams(¶ms)) + return; + + string svcname; + if (!params.GetProperty("service", &svcname)) + return; + + Service service = Service::GetByName(svcname); + + long nextCheck; + if (params.GetProperty("next_check", &nextCheck)) + service.SetNextCheck(nextCheck); + + long state, stateType; + if (params.GetProperty("state", &state) && params.GetProperty("state_type", &stateType)) { + long old_state, old_stateType; + old_state = service.GetState(); + old_stateType = service.GetStateType(); + + if (state != old_state) { + time_t now; + time(&now); + + service.SetLastStateChange(now); + + if (old_stateType != stateType) + service.SetLastHardStateChange(now); + } + + service.SetState(static_cast(state)); + service.SetStateType(static_cast(stateType)); + } + + long attempt; + if (params.GetProperty("current_attempt", &attempt)) + service.SetCurrentCheckAttempt(attempt); + + Dictionary::Ptr cr; + if (params.GetProperty("result", &cr)) + service.SetLastCheckResult(cr); + + time_t now; + time(&now); + CIB::UpdateTaskStatistics(now, 1); +} + +EXPORT_COMPONENT(cibsync, CIBSyncComponent); diff --git a/components/cibsync/cibsynccomponent.h b/components/cibsync/cibsynccomponent.h new file mode 100644 index 000000000..dc71fe6e2 --- /dev/null +++ b/components/cibsync/cibsynccomponent.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * 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 CIBSYNCCOMPONENT_H +#define CIBSYNCCOMPONENT_H + +namespace icinga +{ + +/** + * @ingroup cibsync + */ +class CIBSyncComponent : public Component +{ +public: + virtual string GetName(void) const; + virtual void Start(void); + virtual void Stop(void); + +private: + VirtualEndpoint::Ptr m_Endpoint; + + static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); +}; + +} + +#endif /* CIBSYNCCOMPONENT_H */ diff --git a/components/cibsync/i2-cibsync.h b/components/cibsync/i2-cibsync.h new file mode 100644 index 000000000..858444f98 --- /dev/null +++ b/components/cibsync/i2-cibsync.h @@ -0,0 +1,36 @@ +/****************************************************************************** + * 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 I2CIBSYNC_H +#define I2CIBSYNC_H + +/** + * @defgroup cibsync CIB synchronisation component + * + * Collects update messages to synchronize the local CIB. + */ + +#include +#include +#include +#include + +#include "cibsynccomponent.h" + +#endif /* I2CIBSYNC_H */ diff --git a/components/compat/Makefile.am b/components/compat/Makefile.am index ea353d109..9a464f003 100644 --- a/components/compat/Makefile.am +++ b/components/compat/Makefile.am @@ -12,7 +12,8 @@ compat_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ - -I${top_srcdir}/icinga + -I${top_srcdir}/icinga \ + -I${top_srcdir}/cib compat_la_LDFLAGS = \ $(BOOST_LDFLAGS) \ @@ -24,4 +25,5 @@ compat_la_LDFLAGS = \ compat_la_LIBADD = \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ - ${top_builddir}/icinga/libicinga.la + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/cib/libcib.la diff --git a/components/compat/i2-compat.h b/components/compat/i2-compat.h index 4ca14d47d..aaae6b323 100644 --- a/components/compat/i2-compat.h +++ b/components/compat/i2-compat.h @@ -29,6 +29,7 @@ #include #include #include +#include #include diff --git a/components/delegation/Makefile.am b/components/delegation/Makefile.am index 133f4d2c2..d05bc903f 100644 --- a/components/delegation/Makefile.am +++ b/components/delegation/Makefile.am @@ -12,7 +12,8 @@ delegation_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ - -I${top_srcdir}/icinga + -I${top_srcdir}/icinga \ + -I${top_srcdir}/cib delegation_la_LDFLAGS = \ $(BOOST_LDFLAGS) \ @@ -24,4 +25,5 @@ delegation_la_LDFLAGS = \ delegation_la_LIBADD = \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ - ${top_builddir}/icinga/libicinga.la + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/cib/libcib.la diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index dba68c923..e85316633 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -48,6 +48,8 @@ void DelegationComponent::Start(void) EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint); EndpointManager::GetInstance()->OnNewEndpoint.connect(bind(&DelegationComponent::NewEndpointHandler, this, _2)); + + CIB::RequireInformation(CIB_Configuration); } void DelegationComponent::Stop(void) diff --git a/components/delegation/i2-delegation.h b/components/delegation/i2-delegation.h index 91e633ee5..69382d4a7 100644 --- a/components/delegation/i2-delegation.h +++ b/components/delegation/i2-delegation.h @@ -28,6 +28,7 @@ #include #include +#include #include "delegationcomponent.h" diff --git a/components/discovery/Makefile.am b/components/discovery/Makefile.am index 3f3b6a300..37a9220d4 100644 --- a/components/discovery/Makefile.am +++ b/components/discovery/Makefile.am @@ -14,7 +14,8 @@ discovery_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ - -I${top_srcdir}/icinga + -I${top_srcdir}/icinga \ + -I${top_srcdir}/cib discovery_la_LDFLAGS = \ $(BOOST_LDFLAGS) \ @@ -26,4 +27,5 @@ discovery_la_LDFLAGS = \ discovery_la_LIBADD = \ ${top_builddir}/base/libbase.la \ ${top_builddir}/jsonrpc/libjsonrpc.la \ - ${top_builddir}/icinga/libicinga.la + ${top_builddir}/icinga/libicinga.la \ + ${top_builddir}/cib/libcib.la diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp index dc8de5684..a1f598e0f 100644 --- a/components/discovery/discoverycomponent.cpp +++ b/components/discovery/discoverycomponent.cpp @@ -62,6 +62,8 @@ void DiscoveryComponent::Start(void) /* call the timer as soon as possible */ m_DiscoveryTimer->Reschedule(0); + + CIB::RequireInformation(CIB_Configuration); } /** diff --git a/components/discovery/i2-discovery.h b/components/discovery/i2-discovery.h index 834454087..8d1139be0 100644 --- a/components/discovery/i2-discovery.h +++ b/components/discovery/i2-discovery.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "discoverymessage.h" #include "discoverycomponent.h" diff --git a/configure.ac b/configure.ac index 172b88dc7..27c47bb5a 100644 --- a/configure.ac +++ b/configure.ac @@ -66,8 +66,10 @@ AC_CHECK_LIB(shlwapi, PathRemoveFileSpecA) AC_CONFIG_FILES([ Makefile base/Makefile +cib/Makefile components/Makefile components/checker/Makefile +components/cibsync/Makefile components/compat/Makefile components/configfile/Makefile components/configrpc/Makefile @@ -75,7 +77,6 @@ components/delegation/Makefile components/demo/Makefile components/discovery/Makefile dyn/Makefile -dyntest/Makefile icinga/Makefile icinga-app/Makefile jsonrpc/Makefile diff --git a/dyntest/Makefile.am b/dyntest/Makefile.am deleted file mode 100644 index 6bd7b6554..000000000 --- a/dyntest/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -## Process this file with automake to produce Makefile.in - - -bin_PROGRAMS = \ - dyntest - -dyntest_SOURCES = \ - dyntest.cpp - -dyntest_CPPFLAGS = \ - -DI2_DYNTEST_BUILD \ - $(BOOST_CPPFLAGS) \ - -I${top_srcdir}/base \ - -I${top_srcdir}/dyn \ - -I${top_srcdir}/jsonrpc \ - -I${top_srcdir} - -dyntest_LDFLAGS = \ - $(BOOST_LDFLAGS) - -dyntest_LDADD = \ - ${top_builddir}/base/libbase.la \ - ${top_builddir}/dyn/libdyn.la \ - ${top_builddir}/jsonrpc/libjsonrpc.la diff --git a/dyntest/dyntest.cpp b/dyntest/dyntest.cpp deleted file mode 100644 index 3f2c4b35c..000000000 --- a/dyntest/dyntest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -//#include - -using std::cout; -using std::endl; - -using namespace icinga; - -int main(int argc, char **argv) -{ - if (argc < 2) { - cout << "Syntax: " << argv[0] << " " << endl; - return 1; - } - - for (int i = 0; i < 1; i++) { - vector objects = ConfigCompiler::CompileFile(string(argv[1])); - - ConfigVM::ExecuteItems(objects); - } - -/* ObjectSet::Iterator it; - for (it = DynamicObject::GetAllObjects()->Begin(); it != DynamicObject::GetAllObjects()->End(); it++) { - DynamicObject::Ptr obj = *it; - cout << "Object, name: " << obj->GetName() << ", type: " << obj->GetType() << endl; - - MessagePart mp(obj->GetConfig()); - cout << mp.ToJsonString() << endl; - } -*/ - return 0; -} diff --git a/dyntest/dyntest.vcxproj b/dyntest/dyntest.vcxproj deleted file mode 100644 index 495ff32a8..000000000 --- a/dyntest/dyntest.vcxproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {E6FA740D-0939-4711-AFBC-3D9E913510A1} - Win32Proj - dyntest - - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - true - $(SolutionDir)\base;$(SolutionDir)\dyn;$(IncludePath) - $(OutDir);$(LibraryPath) - - - false - $(SolutionDir)\base;$(SolutionDir)\dyn;$(IncludePath) - $(OutDir);$(LibraryPath) - - - - - - Level3 - Disabled - true - false - - - Console - true - base.lib;dyn.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - true - true - base.lib;dyn.lib;%(AdditionalDependencies) - - - - - - - - - \ No newline at end of file diff --git a/dyntest/dyntest.vcxproj.filters b/dyntest/dyntest.vcxproj.filters deleted file mode 100644 index 5fa60e082..000000000 --- a/dyntest/dyntest.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Quelldateien - - - \ No newline at end of file diff --git a/icinga/Makefile.am b/icinga/Makefile.am index 5a2a64738..52405e656 100644 --- a/icinga/Makefile.am +++ b/icinga/Makefile.am @@ -5,35 +5,15 @@ pkglib_LTLIBRARIES = \ libicinga.la libicinga_la_SOURCES = \ - checkresult.cpp \ - checkresult.h \ - checktask.cpp \ - checktask.h \ - cib.cpp \ - cib.h \ - configobjectadapter.cpp \ - configobjectadapter.h \ endpoint.cpp \ endpoint.h \ endpointmanager.cpp \ endpointmanager.h \ icingaapplication.cpp \ icingaapplication.h \ - host.cpp \ - host.h \ - hostgroup.cpp \ - hostgroup.h \ i2-icinga.h \ jsonrpcendpoint.cpp \ jsonrpcendpoint.h \ - macroprocessor.cpp \ - macroprocessor.h \ - nagioschecktask.cpp \ - nagioschecktask.h \ - service.cpp \ - service.h \ - servicegroup.cpp \ - servicegroup.h \ virtualendpoint.cpp \ virtualendpoint.h @@ -43,7 +23,6 @@ libicinga_la_CPPFLAGS = \ -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc \ -I${top_srcdir}/cJSON \ - -I${top_srcdir}/third-party/popen-noshell \ -I${top_srcdir} libicinga_la_LDFLAGS = \ @@ -55,5 +34,4 @@ libicinga_la_LDFLAGS = \ libicinga_la_LIBADD = \ $(BOOST_THREAD_LIB) \ ${top_builddir}/jsonrpc/libjsonrpc.la \ - ${top_builddir}/base/libbase.la \ - ${top_builddir}/third-party/popen-noshell/libpopen_noshell.la + ${top_builddir}/base/libbase.la diff --git a/icinga/cib.cpp b/icinga/cib.cpp deleted file mode 100644 index 8c2084234..000000000 --- a/icinga/cib.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "i2-icinga.h" - -using namespace icinga; - -int CIB::m_Types; -VirtualEndpoint::Ptr CIB::m_Endpoint; -Ringbuffer CIB::m_TaskStatistics(15 * 60); - -void CIB::RequireInformation(InformationType types) -{ - m_Types |= types; -} - -void CIB::Start(void) -{ - m_Endpoint = boost::make_shared(); - if (m_Types & CIB_ServiceStatus) { - m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus", - boost::bind(&CIB::ServiceStatusRequestHandler, _2, _3)); - } - EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint); -} - -void CIB::ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request) -{ - MessagePart params; - if (!request.GetParams(¶ms)) - return; - - string svcname; - if (!params.GetProperty("service", &svcname)) - return; - - Service service = Service::GetByName(svcname); - - long nextCheck; - if (params.GetProperty("next_check", &nextCheck)) - service.SetNextCheck(nextCheck); - - long state, stateType; - if (params.GetProperty("state", &state) && params.GetProperty("state_type", &stateType)) { - long old_state, old_stateType; - old_state = service.GetState(); - old_stateType = service.GetStateType(); - - if (state != old_state) { - time_t now; - time(&now); - - service.SetLastStateChange(now); - - if (old_stateType != stateType) - service.SetLastHardStateChange(now); - } - - service.SetState(static_cast(state)); - service.SetStateType(static_cast(stateType)); - } - - long attempt; - if (params.GetProperty("current_attempt", &attempt)) - service.SetCurrentCheckAttempt(attempt); - - Dictionary::Ptr cr; - if (params.GetProperty("result", &cr)) - service.SetLastCheckResult(cr); - - time_t now; - time(&now); - m_TaskStatistics.InsertValue(now, 1); -} - -int CIB::GetTaskStatistics(long timespan) -{ - return m_TaskStatistics.GetValues(timespan); -} diff --git a/icinga/i2-icinga.h b/icinga/i2-icinga.h index 8794751b2..a9284165b 100644 --- a/icinga/i2-icinga.h +++ b/icinga/i2-icinga.h @@ -46,17 +46,4 @@ using boost::algorithm::is_any_of; #include "endpointmanager.h" #include "icingaapplication.h" -#include "configobjectadapter.h" -#include "host.h" -#include "hostgroup.h" -#include "service.h" -#include "servicegroup.h" - -#include "cib.h" - -#include "macroprocessor.h" -#include "checkresult.h" -#include "checktask.h" -#include "nagioschecktask.h" - #endif /* I2ICINGA_H */ diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index d4a92ae78..16b9f9e3f 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -96,9 +96,6 @@ int IcingaApplication::Main(const vector& args) if (!service.empty()) EndpointManager::GetInstance()->AddListener(service); - CIB::RequireInformation(CIB_ServiceStatus); - CIB::Start(); - RunEventLoop(); return EXIT_SUCCESS;