Moved CIB stuff into a separate library and loadable component.

This commit is contained in:
Gunnar Beutner 2012-07-02 12:34:54 +02:00
parent c9a74ef3ed
commit f2420fb17a
47 changed files with 368 additions and 308 deletions

View File

@ -8,8 +8,8 @@ SUBDIRS = \
base \
dyn \
jsonrpc \
dyntest \
icinga \
cib \
components \
icinga-app \
test

47
cib/Makefile.am Normal file
View File

@ -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

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

35
cib/cib.cpp Normal file
View File

@ -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;
}

View File

@ -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);
};
}

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

32
cib/i2-cib.h Normal file
View File

@ -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 */

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
#ifndef _MSC_VER
# include "popen_noshell.h"

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -1,4 +1,4 @@
#include "i2-icinga.h"
#include "i2-cib.h"
using namespace icinga;

View File

@ -3,6 +3,7 @@
SUBDIRS = \
checker \
cibsync \
compat \
configfile \
configrpc \

View 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

View File

@ -28,6 +28,7 @@
#include <i2-base.h>
#include <i2-icinga.h>
#include <i2-cib.h>
#include <queue>

View File

@ -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

View File

@ -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);

View File

@ -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 */

View File

@ -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 */

View 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

View File

@ -29,6 +29,7 @@
#include <i2-base.h>
#include <i2-jsonrpc.h>
#include <i2-icinga.h>
#include <i2-cib.h>
#include <fstream>

View 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

View 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)

View File

@ -28,6 +28,7 @@
#include <i2-base.h>
#include <i2-icinga.h>
#include <i2-cib.h>
#include "delegationcomponent.h"

View 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

View File

@ -62,6 +62,8 @@ void DiscoveryComponent::Start(void)
/* call the timer as soon as possible */
m_DiscoveryTimer->Reschedule(0);
CIB::RequireInformation(CIB_Configuration);
}
/**

View 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"

View 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

View File

@ -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

View File

@ -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;
}

View File

@ -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>

View File

@ -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>

View 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

View File

@ -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);
}

View 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 */

View 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;