]> granicus.if.org Git - icinga2/commitdiff
Moved CIB stuff into a separate library and loadable component.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 10:34:54 +0000 (12:34 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 10:34:54 +0000 (12:34 +0200)
47 files changed:
Makefile.am
cib/Makefile.am [new file with mode: 0644]
cib/checkresult.cpp [moved from icinga/checkresult.cpp with 98% similarity]
cib/checkresult.h [moved from icinga/checkresult.h with 100% similarity]
cib/checktask.cpp [moved from icinga/checktask.cpp with 98% similarity]
cib/checktask.h [moved from icinga/checktask.h with 100% similarity]
cib/cib.cpp [new file with mode: 0644]
cib/cib.h [moved from icinga/cib.h with 68% similarity]
cib/configobjectadapter.cpp [moved from icinga/configobjectadapter.cpp with 94% similarity]
cib/configobjectadapter.h [moved from icinga/configobjectadapter.h with 100% similarity]
cib/host.cpp [moved from icinga/host.cpp with 96% similarity]
cib/host.h [moved from icinga/host.h with 100% similarity]
cib/hostgroup.cpp [moved from icinga/hostgroup.cpp with 97% similarity]
cib/hostgroup.h [moved from icinga/hostgroup.h with 100% similarity]
cib/i2-cib.h [new file with mode: 0644]
cib/macroprocessor.cpp [moved from icinga/macroprocessor.cpp with 97% similarity]
cib/macroprocessor.h [moved from icinga/macroprocessor.h with 100% similarity]
cib/nagioschecktask.cpp [moved from icinga/nagioschecktask.cpp with 99% similarity]
cib/nagioschecktask.h [moved from icinga/nagioschecktask.h with 100% similarity]
cib/service.cpp [moved from icinga/service.cpp with 99% similarity]
cib/service.h [moved from icinga/service.h with 100% similarity]
cib/servicegroup.cpp [moved from icinga/servicegroup.cpp with 97% similarity]
cib/servicegroup.h [moved from icinga/servicegroup.h with 100% similarity]
components/Makefile.am
components/checker/Makefile.am
components/checker/i2-checker.h
components/cibsync/Makefile.am [new file with mode: 0644]
components/cibsync/cibsynccomponent.cpp [new file with mode: 0644]
components/cibsync/cibsynccomponent.h [new file with mode: 0644]
components/cibsync/i2-cibsync.h [new file with mode: 0644]
components/compat/Makefile.am
components/compat/i2-compat.h
components/delegation/Makefile.am
components/delegation/delegationcomponent.cpp
components/delegation/i2-delegation.h
components/discovery/Makefile.am
components/discovery/discoverycomponent.cpp
components/discovery/i2-discovery.h
configure.ac
dyntest/Makefile.am [deleted file]
dyntest/dyntest.cpp [deleted file]
dyntest/dyntest.vcxproj [deleted file]
dyntest/dyntest.vcxproj.filters [deleted file]
icinga/Makefile.am
icinga/cib.cpp [deleted file]
icinga/i2-icinga.h
icinga/icingaapplication.cpp

index 030f64b1efae864b4576e233cb1a19738b04a1ba..4fec7325ec4c2f6251910312712bb48f58cdd972 100644 (file)
@@ -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 (file)
index 0000000..f880261
--- /dev/null
@@ -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
similarity index 98%
rename from icinga/checkresult.cpp
rename to cib/checkresult.cpp
index 9377dd1a6b01f2c7d26f3e11a3c8df72334098d2..eca5775467b010e7caeec1d88921fed526b0e399 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 100%
rename from icinga/checkresult.h
rename to cib/checkresult.h
similarity index 98%
rename from icinga/checktask.cpp
rename to cib/checktask.cpp
index 1799b049024ec8630e3d0491962a1db83d0db120..5b5ac8410c1f81f4fbbb9df107d829d912de9197 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
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 (file)
index 0000000..a562bc6
--- /dev/null
@@ -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<ConfigObject>("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;
+}
similarity index 68%
rename from icinga/cib.h
rename to cib/cib.h
index c01a3f389ea550ef9f859e8b4c4dad26ec2cf73a..8bff7780ed470c19f10e12eb0d8a95e89de88e6a 100644 (file)
+++ 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);
 };
 
 }
similarity index 94%
rename from icinga/configobjectadapter.cpp
rename to cib/configobjectadapter.cpp
index 7da5cdf2b20f5bf9e823c82e81eca7bb392a37c1..a0f32e76f39c96cfa33f9c61655cecce4e493273 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 96%
rename from icinga/host.cpp
rename to cib/host.cpp
index cfda2796ad1b7ed3d58031a3a4ee1d0eade11187..c99dd15aa45da91ff35c1757f520a8a98fbc1f0c 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 100%
rename from icinga/host.h
rename to cib/host.h
similarity index 97%
rename from icinga/hostgroup.cpp
rename to cib/hostgroup.cpp
index 903dfdd4e0e13679824f7239f3f0a278d3cd8c7e..6c8f2c3988dd3c95a4a62daef301e769abbc4efd 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
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 (file)
index 0000000..6a5d382
--- /dev/null
@@ -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 <i2-icinga.h>
+
+#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 */
similarity index 97%
rename from icinga/macroprocessor.cpp
rename to cib/macroprocessor.cpp
index 291161e781c46b3cc77300d5ba25675c1a561342..7a699585f5786504f05ab3a8fb9d882d485cc00e 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 100%
rename from icinga/macroprocessor.h
rename to cib/macroprocessor.h
similarity index 99%
rename from icinga/nagioschecktask.cpp
rename to cib/nagioschecktask.cpp
index 30c3de97de2ea97a3ace59c01680983cd136fec1..f9a0cbe8a4156fc4572a196c0d6451f2cd923f2e 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 #ifndef _MSC_VER
 #      include "popen_noshell.h"
similarity index 99%
rename from icinga/service.cpp
rename to cib/service.cpp
index 2c8621c172bc48f561125790be310d9b368208c5..60837c6c963f74b70772f5cec622cc1c1bc86efb 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 100%
rename from icinga/service.h
rename to cib/service.h
similarity index 97%
rename from icinga/servicegroup.cpp
rename to cib/servicegroup.cpp
index 24496af4bb4e67b3ad9967d646cfc766cca16571..769f21081efc648da2a2633a964c35cc95c66465 100644 (file)
@@ -1,4 +1,4 @@
-#include "i2-icinga.h"
+#include "i2-cib.h"
 
 using namespace icinga;
 
similarity index 100%
rename from icinga/servicegroup.h
rename to cib/servicegroup.h
index 781a6f53fa081922ef91ee0e4c360f830ee04901..d8211bb52c05ddbe92f77de6b26049d279469783 100644 (file)
@@ -3,6 +3,7 @@
 
 SUBDIRS = \
        checker \
+       cibsync \
        compat \
        configfile \
        configrpc \
index 63f35d0af128f3fb066598f0c8a4dc5f82e8e568..d1d9cf63b821fc10490deb52899c8cda87fb09b3 100644 (file)
@@ -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
index 8a0ad53de2b9759acd168793a8d9217432cf491c..b142c84d6a303dc4dac4fbb6073558c324df4ffa 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <i2-base.h>
 #include <i2-icinga.h>
+#include <i2-cib.h>
 
 #include <queue>
 
diff --git a/components/cibsync/Makefile.am b/components/cibsync/Makefile.am
new file mode 100644 (file)
index 0000000..7f677c2
--- /dev/null
@@ -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 (file)
index 0000000..a616fd3
--- /dev/null
@@ -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<VirtualEndpoint>();
+       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(&params))
+               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<ServiceState>(state));
+               service.SetStateType(static_cast<ServiceStateType>(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 (file)
index 0000000..dc71fe6
--- /dev/null
@@ -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 (file)
index 0000000..858444f
--- /dev/null
@@ -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 <i2-base.h>
+#include <i2-jsonrpc.h>
+#include <i2-icinga.h>
+#include <i2-cib.h>
+
+#include "cibsynccomponent.h"
+
+#endif /* I2CIBSYNC_H */
index ea353d1090846b00c5cba16510341eacd26e5d15..9a464f003d739aa5c16675229d3f398894de10b7 100644 (file)
@@ -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
index 4ca14d47d2647afa8589f631a170f4e097e0a78e..aaae6b323c1c9f662658b0fecd534c874008fc4b 100644 (file)
@@ -29,6 +29,7 @@
 #include <i2-base.h>
 #include <i2-jsonrpc.h>
 #include <i2-icinga.h>
+#include <i2-cib.h>
 
 #include <fstream>
 
index 133f4d2c25f16e9e586d659d0bd48a8cea8e2686..d05bc903ffb5eea633abda497142479fde5be125 100644 (file)
@@ -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
index dba68c9231cc4a4c092f6e574df3c50418663d6b..e85316633843dae4df057cdfec857694bd27cb66 100644 (file)
@@ -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)
index 91e633ee55f6f01f2769324d94e8f04444e4fd15..69382d4a7bbcd03eceb312ecf72dac672c7e0fcc 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <i2-base.h>
 #include <i2-icinga.h>
+#include <i2-cib.h>
 
 #include "delegationcomponent.h"
 
index 3f3b6a300eb85d49e03604cb21a4cde86df59913..37a9220d45495df32412db2b0f6611f4925f262e 100644 (file)
@@ -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
index dc8de5684b993847ddab94f131cc71fb836115dc..a1f598e0f2444887503d19bfd9874e113cff2f26 100644 (file)
@@ -62,6 +62,8 @@ void DiscoveryComponent::Start(void)
 
        /* call the timer as soon as possible */
        m_DiscoveryTimer->Reschedule(0);
+
+       CIB::RequireInformation(CIB_Configuration);
 }
 
 /**
index 834454087c1c8e5b7ac5b98da3da803f9f17e8c0..8d1139be0fa4c1fd80bff2cb7d940fb78b430315 100644 (file)
@@ -30,6 +30,7 @@
 #include <i2-base.h>
 #include <i2-jsonrpc.h>
 #include <i2-icinga.h>
+#include <i2-cib.h>
 
 #include "discoverymessage.h"
 #include "discoverycomponent.h"
index 172b88dc7d6675270f951aaa407f3b89237259b8..27c47bb5aee73dcbc077ff5c284e5def12abd587 100644 (file)
@@ -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 (file)
index 6bd7b65..0000000
+++ /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 (file)
index 3f2c4b3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <i2-dyn.h>
-//#include <i2-jsonrpc.h>
-
-using std::cout;
-using std::endl;
-
-using namespace icinga;
-
-int main(int argc, char **argv)
-{
-       if (argc < 2) {
-               cout << "Syntax: " << argv[0] << " <filename>" << endl;
-               return 1;
-       }
-
-       for (int i = 0; i < 1; i++) {
-               vector<ConfigItem::Ptr> objects = ConfigCompiler::CompileFile(string(argv[1]));
-
-               ConfigVM::ExecuteItems(objects);
-       }
-
-/*     ObjectSet<DynamicObject::Ptr>::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 (file)
index 495ff32..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{E6FA740D-0939-4711-AFBC-3D9E913510A1}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>dyntest</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <MinimalRebuild>false</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;dyn.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <MinimalRebuild>false</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;dyn.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="dyntest.cpp" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/dyntest/dyntest.vcxproj.filters b/dyntest/dyntest.vcxproj.filters
deleted file mode 100644 (file)
index 5fa60e0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Quelldateien">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Headerdateien">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Ressourcendateien">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="dyntest.cpp">
-      <Filter>Quelldateien</Filter>
-    </ClCompile>
-  </ItemGroup>
-</Project>
\ No newline at end of file
index 5a2a64738ee6d1cc4b19c79c4b8fc491585f2724..52405e65637fa2680360d796f9757306648d6a4e 100644 (file)
@@ -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 (file)
index 8c20842..0000000
+++ /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<VirtualEndpoint>();
-       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(&params))
-               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<ServiceState>(state));
-               service.SetStateType(static_cast<ServiceStateType>(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);
-}
index 8794751b2726181b0e1a8eb314b05a4e05fd62c1..a9284165bdbaa86f781a3db5ad0ef2abe41189dc 100644 (file)
@@ -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 */
index d4a92ae7817c90e5f26ecace84b3f33df2d19bae..16b9f9e3f5ce9414f6fe0beb00b67aa297305724 100644 (file)
@@ -96,9 +96,6 @@ int IcingaApplication::Main(const vector<string>& args)
        if (!service.empty())
                EndpointManager::GetInstance()->AddListener(service);
 
-       CIB::RequireInformation(CIB_ServiceStatus);
-       CIB::Start();
-
        RunEventLoop();
 
        return EXIT_SUCCESS;