]> granicus.if.org Git - icinga2/commitdiff
Merged convenience component into libicinga.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 21 Sep 2012 11:49:14 +0000 (13:49 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 21 Sep 2012 11:49:14 +0000 (13:49 +0200)
14 files changed:
components/Makefile.am
components/convenience/Makefile.am [deleted file]
components/convenience/convenience.vcxproj [deleted file]
components/convenience/convenience.vcxproj.filters [deleted file]
components/convenience/conveniencecomponent.cpp [deleted file]
components/convenience/conveniencecomponent.h [deleted file]
components/convenience/i2-convenience.h [deleted file]
configure.ac
icinga-app/Makefile.am
icinga2.sln
lib/base/streamlogger.cpp
lib/icinga/host.cpp
lib/icinga/host.h
lib/icinga/icingaapplication.cpp

index 16f0cc366897e16422cfb7d6537edf9d02d71dbb..837b8f59ecb28ecb7e96f72b24ee84eb2829be95 100644 (file)
@@ -4,7 +4,6 @@
 SUBDIRS = \
        checker \
        compat \
-       convenience \
        delegation \
        demo \
        replication
diff --git a/components/convenience/Makefile.am b/components/convenience/Makefile.am
deleted file mode 100644 (file)
index 6d2f126..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-pkglib_LTLIBRARIES = \
-       convenience.la
-
-convenience_la_SOURCES = \
-       conveniencecomponent.cpp \
-       conveniencecomponent.h \
-       i2-convenience.h
-
-convenience_la_CPPFLAGS = \
-       $(BOOST_CPPFLAGS) \
-       -I${top_srcdir}/lib/base \
-       -I${top_srcdir}/lib/config \
-       -I${top_srcdir}/lib/remoting \
-       -I${top_srcdir}/lib/icinga
-
-convenience_la_LDFLAGS = \
-       $(BOOST_LDFLAGS) \
-       -module \
-       -no-undefined \
-       @RELEASE_INFO@ \
-       @VERSION_INFO@
-
-convenience_la_LIBADD = \
-       $(BOOST_SIGNALS_LIB) \
-       $(BOOST_THREAD_LIB) \
-       ${top_builddir}/lib/base/libbase.la \
-       ${top_builddir}/lib/config/libconfig.la \
-       ${top_builddir}/lib/remoting/libremoting.la \
-       ${top_builddir}/lib/icinga/libicinga.la
diff --git a/components/convenience/convenience.vcxproj b/components/convenience/convenience.vcxproj
deleted file mode 100644 (file)
index 39cd65b..0000000
+++ /dev/null
@@ -1,90 +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>{D02A349B-BAF7-41FB-86FF-B05BA05FE578}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>convenience</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</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)\lib\base;$(SolutionDir)\lib\remoting;$(SolutionDir)\lib\icinga;$(SolutionDir)\lib\config;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(SolutionDir)\lib\base;$(SolutionDir)\lib\remoting;$(SolutionDir)\lib\icinga;$(SolutionDir)\lib\config;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CONVENIENCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;config.lib;remoting.lib;icinga.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CONVENIENCE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;config.lib;remoting.lib;icinga.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="conveniencecomponent.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="conveniencecomponent.h" />
-    <ClInclude Include="i2-convenience.h" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/components/convenience/convenience.vcxproj.filters b/components/convenience/convenience.vcxproj.filters
deleted file mode 100644 (file)
index 9a47a83..0000000
+++ /dev/null
@@ -1,30 +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="conveniencecomponent.cpp">
-      <Filter>Quelldateien</Filter>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="conveniencecomponent.h">
-      <Filter>Headerdateien</Filter>
-    </ClInclude>
-    <ClInclude Include="i2-convenience.h">
-      <Filter>Headerdateien</Filter>
-    </ClInclude>
-  </ItemGroup>
-</Project>
\ No newline at end of file
diff --git a/components/convenience/conveniencecomponent.cpp b/components/convenience/conveniencecomponent.cpp
deleted file mode 100644 (file)
index e4caea2..0000000
+++ /dev/null
@@ -1,164 +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.             *
- ******************************************************************************/
-
-#include "i2-convenience.h"
-
-using namespace icinga;
-
-/**
- * Starts the component.
- */
-void ConvenienceComponent::Start(void)
-{
-       ConfigItem::OnCommitted.connect(boost::bind(&ConvenienceComponent::ObjectCommittedHandler, this, _1));
-       ConfigItem::OnRemoved.connect(boost::bind(&ConvenienceComponent::ObjectRemovedHandler, this, _1));
-}
-
-template<typename TDict>
-static void CopyServiceAttributes(const Host::Ptr& host, TDict serviceDesc,
-    const ConfigItemBuilder::Ptr& builder)
-{
-       /* TODO: we only need to copy macros if this is an inline definition,
-        * i.e. host->GetProperties() != service, however for now we just
-        * copy them anyway. */
-       Value macros = serviceDesc->Get("macros");
-       if (!macros.IsEmpty())
-               builder->AddExpression("macros", OperatorPlus, macros);
-
-       Value checkInterval = serviceDesc->Get("check_interval");
-       if (!checkInterval.IsEmpty())
-               builder->AddExpression("check_interval", OperatorSet, checkInterval);
-
-       Value retryInterval = serviceDesc->Get("retry_interval");
-       if (!retryInterval.IsEmpty())
-               builder->AddExpression("retry_interval", OperatorSet, retryInterval);
-
-       Value sgroups = serviceDesc->Get("servicegroups");
-       if (!sgroups.IsEmpty())
-               builder->AddExpression("servicegroups", OperatorPlus, sgroups);
-
-       Value checkers = serviceDesc->Get("checkers");
-       if (!checkers.IsEmpty())
-               builder->AddExpression("checkers", OperatorSet, checkers);
-
-       Value dependencies = serviceDesc->Get("dependencies");
-       if (!dependencies.IsEmpty())
-               builder->AddExpression("dependencies", OperatorPlus,
-                   Service::ResolveDependencies(host, dependencies));
-
-       Value hostchecks = serviceDesc->Get("hostchecks");
-       if (!hostchecks.IsEmpty())
-               builder->AddExpression("dependencies", OperatorPlus,
-                   Service::ResolveDependencies(host, hostchecks));
-}
-
-void ConvenienceComponent::ObjectCommittedHandler(const ConfigItem::Ptr& item)
-{
-       if (item->GetType() != "Host")
-               return;
-
-       /* ignore abstract host objects */
-       if (!Host::Exists(item->GetName()))
-               return;
-
-       Host::Ptr host = Host::GetByName(item->GetName());
-
-       Dictionary::Ptr oldServices = host->Get("convenience_services");
-
-       Dictionary::Ptr newServices;
-       newServices = boost::make_shared<Dictionary>();
-
-       Dictionary::Ptr serviceDescs = host->Get("services");
-
-       if (serviceDescs) {
-               String svcname;
-               Value svcdesc;
-               BOOST_FOREACH(tie(svcname, svcdesc), serviceDescs) {
-                       stringstream namebuf;
-                       namebuf << item->GetName() << "-" << svcname;
-                       String name = namebuf.str();
-
-                       ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(item->GetDebugInfo());
-                       builder->SetType("Service");
-                       builder->SetName(name);
-                       builder->AddExpression("host_name", OperatorSet, item->GetName());
-                       builder->AddExpression("alias", OperatorSet, svcname);
-
-                       CopyServiceAttributes(host, host, builder);
-
-                       if (svcdesc.IsScalar()) {
-                               builder->AddParent(svcdesc);
-                       } else if (svcdesc.IsObjectType<Dictionary>()) {
-                               Dictionary::Ptr service = svcdesc;
-
-                               String parent = service->Get("service");
-                               if (parent.IsEmpty())
-                                       parent = svcname;
-
-                               builder->AddParent(parent);
-
-                               CopyServiceAttributes(host, service, builder);
-                       } else {
-                               throw_exception(invalid_argument("Service description must be either a string or a dictionary."));
-                       }
-
-                       ConfigItem::Ptr serviceItem = builder->Compile();
-                       serviceItem->Commit();
-
-                       newServices->Set(name, serviceItem);
-               }
-       }
-
-       if (oldServices) {
-               ConfigItem::Ptr service;
-               BOOST_FOREACH(tie(tuples::ignore, service), oldServices) {
-                       if (!service)
-                               continue;
-
-                       if (!newServices->Contains(service->GetName()))
-                               service->Unregister();
-               }
-       }
-
-       host->Set("convenience_services", newServices);
-}
-
-void ConvenienceComponent::ObjectRemovedHandler(const ConfigItem::Ptr& item)
-{
-       if (item->GetType() != "Host")
-               return;
-
-       DynamicObject::Ptr host = item->GetDynamicObject();
-
-       if (!host)
-               return;
-
-       Dictionary::Ptr services = host->Get("convenience_services");
-
-       if (!services)
-               return;
-
-       ConfigItem::Ptr service;
-       BOOST_FOREACH(tie(tuples::ignore, service), services) {
-               service->Unregister();
-       }
-}
-
-EXPORT_COMPONENT(convenience, ConvenienceComponent);
-
diff --git a/components/convenience/conveniencecomponent.h b/components/convenience/conveniencecomponent.h
deleted file mode 100644 (file)
index e1d7db7..0000000
+++ /dev/null
@@ -1,41 +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 CONVENIENCECOMPONENT_H
-#define CONVENIENCECOMPONENT_H
-
-namespace icinga
-{
-
-/**
- * @ingroup convenience
- */
-class ConvenienceComponent : public IComponent
-{
-public:
-       virtual void Start(void);
-
-private:
-       void ObjectCommittedHandler(const ConfigItem::Ptr& item);
-       void ObjectRemovedHandler(const ConfigItem::Ptr& item);
-};
-
-}
-
-#endif /* CONVENIENCECOMPONENT_H */
diff --git a/components/convenience/i2-convenience.h b/components/convenience/i2-convenience.h
deleted file mode 100644 (file)
index a2a9ef4..0000000
+++ /dev/null
@@ -1,38 +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 I2CONVENIENCE_H
-#define I2CONVENIENCE_H
-
-/**
- * @defgroup convenience Convenience component
- *
- * The convenience component takes service definitions from host objects
- * and creates service objects. Technically this isn't strictly necessary but
- * makes defining services a lot easier for users.
- */
-
-#include <i2-base.h>
-#include <i2-config.h>
-#include <i2-remoting.h>
-#include <i2-icinga.h>
-
-#include "conveniencecomponent.h"
-
-#endif /* I2CONVENIENCE_H */
index 707c2fe90055274f37d8133d468037cbe862b948..d91d07e776e65b47419652cb15280eda386d3af7 100644 (file)
@@ -70,7 +70,6 @@ Makefile
 components/Makefile
 components/checker/Makefile
 components/compat/Makefile
-components/convenience/Makefile
 components/delegation/Makefile
 components/demo/Makefile
 components/replication/Makefile
index 3f7e5a68ccc11ceaeccf1f9516600588604b6826..9495c6d3573135524d76abffbdd614193db7b8ea 100644 (file)
@@ -34,10 +34,8 @@ icinga2_LDADD = \
        -dlopen ${top_builddir}/components/checker/checker.la \
        -dlopen ${top_builddir}/components/replication/replication.la \
        -dlopen ${top_builddir}/components/compat/compat.la \
-       -dlopen ${top_builddir}/components/convenience/convenience.la \
        -dlopen ${top_builddir}/components/delegation/delegation.la \
        -dlopen ${top_builddir}/components/demo/demo.la
 
 icinga2_DEPENDENCIES = \
-       ${top_builddir}/components/replication/replication.la \
-       ${top_builddir}/components/convenience/convenience.la
+       ${top_builddir}/components/replication/replication.la
index 8f476609e48eed2e302fc2e53e67fba58329278c..8c39f225333b37edc2785a6849157ff4b9b5ed18 100644 (file)
@@ -7,7 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\ic
                {2E6C1133-730F-4875-A72C-B455B1DD4C5C} = {2E6C1133-730F-4875-A72C-B455B1DD4C5C}
                {17C93245-8C20-4316-9573-1AE41D918C10} = {17C93245-8C20-4316-9573-1AE41D918C10}
                {704DDD8E-9E6D-4C22-80BD-6DE10F3A5E1C} = {704DDD8E-9E6D-4C22-80BD-6DE10F3A5E1C}
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578} = {D02A349B-BAF7-41FB-86FF-B05BA05FE578}
                {38CE81CC-2660-4EF0-A936-4A337591DA3E} = {38CE81CC-2660-4EF0-A936-4A337591DA3E}
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
@@ -41,11 +40,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compat", "components\compat
                {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convenience", "components\convenience\convenience.vcxproj", "{D02A349B-BAF7-41FB-86FF-B05BA05FE578}"
-       ProjectSection(ProjectDependencies) = postProject
-               {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
-       EndProjectSection
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", "{4A1773FD-DDED-4952-8700-C898E890554A}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libraries", "libraries", "{BC82DE9C-42E2-4880-92DA-C2269D2F6416}"
@@ -114,10 +108,6 @@ Global
                {2BD1C70C-43DB-4F44-B66B-67CF5C7044AA}.Debug|Win32.Build.0 = Debug|Win32
                {2BD1C70C-43DB-4F44-B66B-67CF5C7044AA}.Release|Win32.ActiveCfg = Release|Win32
                {2BD1C70C-43DB-4F44-B66B-67CF5C7044AA}.Release|Win32.Build.0 = Release|Win32
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Debug|Win32.ActiveCfg = Debug|Win32
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Debug|Win32.Build.0 = Debug|Win32
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Release|Win32.ActiveCfg = Release|Win32
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Release|Win32.Build.0 = Release|Win32
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Debug|Win32.ActiveCfg = Debug|Win32
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Debug|Win32.Build.0 = Debug|Win32
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Release|Win32.ActiveCfg = Release|Win32
@@ -143,7 +133,6 @@ Global
                {17C93245-8C20-4316-9573-1AE41D918C10} = {4A1773FD-DDED-4952-8700-C898E890554A}
                {704DDD8E-9E6D-4C22-80BD-6DE10F3A5E1C} = {4A1773FD-DDED-4952-8700-C898E890554A}
                {2BD1C70C-43DB-4F44-B66B-67CF5C7044AA} = {4A1773FD-DDED-4952-8700-C898E890554A}
-               {D02A349B-BAF7-41FB-86FF-B05BA05FE578} = {4A1773FD-DDED-4952-8700-C898E890554A}
                {2E6C1133-730F-4875-A72C-B455B1DD4C5C} = {4A1773FD-DDED-4952-8700-C898E890554A}
                {19CBCE06-3F5C-479A-BD75-E2AB6215D345} = {3BE47C55-D74A-46E6-8F8B-470B3FD29FB7}
                {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {3BE47C55-D74A-46E6-8F8B-470B3FD29FB7}
index 758484a142226604f07ba5c31cc658a5f1fe3e6c..bd292878b6aaf54aea1a38a8bf520eb2deb1ca26 100644 (file)
@@ -58,7 +58,7 @@ void StreamLogger::ProcessLogEntry(std::ostream& stream, const LogEntry& entry)
        time_t ts = entry.Timestamp;
        tm tmnow = *localtime(&ts);
 
-       strftime(timestamp, sizeof(timestamp), "%Y/%m/%d %H:%M:%S", &tmnow);
+       strftime(timestamp, sizeof(timestamp), "%a, %d %b %Y %T %z", &tmnow);
 
        stream << "[" << timestamp << "] "
                 << Logger::SeverityToString(entry.Severity) << "/" << entry.Facility << ": "
index f4aff61f14acd57da21251a09f1d4a03f2d65f77..95fe7e0a3b0004d55b2e6caa02f7e6ee3267fe85 100644 (file)
@@ -23,9 +23,18 @@ using namespace icinga;
 
 REGISTER_CLASS(Host);
 
+bool Host::m_InitializerDone = false;
+
 Host::Host(const Dictionary::Ptr& properties)
        : DynamicObject(properties)
 {
+       if (!m_InitializerDone) {
+               ConfigItem::OnCommitted.connect(boost::bind(&Host::ObjectCommittedHandler, this, _1));
+               ConfigItem::OnRemoved.connect(boost::bind(&Host::ObjectRemovedHandler, this, _1));
+
+               m_InitializerDone = true;
+       }
+
        RegisterAttribute("alias", Attribute_Config);
        RegisterAttribute("hostgroups", Attribute_Config);
 }
@@ -127,3 +136,134 @@ bool Host::IsUp(void)
 
        return true;
 }
+
+template<typename TDict>
+static void CopyServiceAttributes(const Host::Ptr& host, TDict serviceDesc,
+    const ConfigItemBuilder::Ptr& builder)
+{
+       /* TODO: we only need to copy macros if this is an inline definition,
+        * i.e. host->GetProperties() != service, however for now we just
+        * copy them anyway. */
+       Value macros = serviceDesc->Get("macros");
+       if (!macros.IsEmpty())
+               builder->AddExpression("macros", OperatorPlus, macros);
+
+       Value checkInterval = serviceDesc->Get("check_interval");
+       if (!checkInterval.IsEmpty())
+               builder->AddExpression("check_interval", OperatorSet, checkInterval);
+
+       Value retryInterval = serviceDesc->Get("retry_interval");
+       if (!retryInterval.IsEmpty())
+               builder->AddExpression("retry_interval", OperatorSet, retryInterval);
+
+       Value sgroups = serviceDesc->Get("servicegroups");
+       if (!sgroups.IsEmpty())
+               builder->AddExpression("servicegroups", OperatorPlus, sgroups);
+
+       Value checkers = serviceDesc->Get("checkers");
+       if (!checkers.IsEmpty())
+               builder->AddExpression("checkers", OperatorSet, checkers);
+
+       Value dependencies = serviceDesc->Get("dependencies");
+       if (!dependencies.IsEmpty())
+               builder->AddExpression("dependencies", OperatorPlus,
+                   Service::ResolveDependencies(host, dependencies));
+
+       Value hostchecks = serviceDesc->Get("hostchecks");
+       if (!hostchecks.IsEmpty())
+               builder->AddExpression("dependencies", OperatorPlus,
+                   Service::ResolveDependencies(host, hostchecks));
+}
+
+void Host::ObjectCommittedHandler(const ConfigItem::Ptr& item)
+{
+       if (item->GetType() != "Host")
+               return;
+
+       /* ignore abstract host objects */
+       if (!Host::Exists(item->GetName()))
+               return;
+
+       Host::Ptr host = Host::GetByName(item->GetName());
+
+       Dictionary::Ptr oldServices = host->Get("convenience_services");
+
+       Dictionary::Ptr newServices;
+       newServices = boost::make_shared<Dictionary>();
+
+       Dictionary::Ptr serviceDescs = host->Get("services");
+
+       if (serviceDescs) {
+               String svcname;
+               Value svcdesc;
+               BOOST_FOREACH(tie(svcname, svcdesc), serviceDescs) {
+                       stringstream namebuf;
+                       namebuf << item->GetName() << "-" << svcname;
+                       String name = namebuf.str();
+
+                       ConfigItemBuilder::Ptr builder = boost::make_shared<ConfigItemBuilder>(item->GetDebugInfo());
+                       builder->SetType("Service");
+                       builder->SetName(name);
+                       builder->AddExpression("host_name", OperatorSet, item->GetName());
+                       builder->AddExpression("alias", OperatorSet, svcname);
+
+                       CopyServiceAttributes(host, host, builder);
+
+                       if (svcdesc.IsScalar()) {
+                               builder->AddParent(svcdesc);
+                       } else if (svcdesc.IsObjectType<Dictionary>()) {
+                               Dictionary::Ptr service = svcdesc;
+
+                               String parent = service->Get("service");
+                               if (parent.IsEmpty())
+                                       parent = svcname;
+
+                               builder->AddParent(parent);
+
+                               CopyServiceAttributes(host, service, builder);
+                       } else {
+                               throw_exception(invalid_argument("Service description must be either a string or a dictionary."));
+                       }
+
+                       ConfigItem::Ptr serviceItem = builder->Compile();
+                       serviceItem->Commit();
+
+                       newServices->Set(name, serviceItem);
+               }
+       }
+
+       if (oldServices) {
+               ConfigItem::Ptr service;
+               BOOST_FOREACH(tie(tuples::ignore, service), oldServices) {
+                       if (!service)
+                               continue;
+
+                       if (!newServices->Contains(service->GetName()))
+                               service->Unregister();
+               }
+       }
+
+       host->Set("convenience_services", newServices);
+}
+
+void Host::ObjectRemovedHandler(const ConfigItem::Ptr& item)
+{
+       if (item->GetType() != "Host")
+               return;
+
+       DynamicObject::Ptr host = item->GetDynamicObject();
+
+       if (!host)
+               return;
+
+       Dictionary::Ptr services = host->Get("convenience_services");
+
+       if (!services)
+               return;
+
+       ConfigItem::Ptr service;
+       BOOST_FOREACH(tie(tuples::ignore, service), services) {
+               service->Unregister();
+       }
+}
+
index 26d06bac09930b9109549e9db9c6b315de02d4bf..48ef812b6a480a3e84d61a91476cd1a10ff19dae 100644 (file)
@@ -46,6 +46,12 @@ public:
 
        bool IsReachable(void);
        bool IsUp(void);
+
+private:
+       static bool m_InitializerDone;
+
+       void ObjectCommittedHandler(const ConfigItem::Ptr& item);
+       void ObjectRemovedHandler(const ConfigItem::Ptr& item);
 };
 
 }
index a2764db6559735418d9f5357c708b0c7ec909c25..4b83891c0091994d2d8e5ffc9ea022621c84048e 100644 (file)
@@ -41,14 +41,6 @@ IcingaApplication::IcingaApplication(const Dictionary::Ptr& serializedUpdate)
        replicationComponentConfig->SetLocal(true);
        replicationComponentConfig->Compile()->Commit();
        replicationComponentConfig.reset();
-
-       /* load convenience config component */
-       ConfigItemBuilder::Ptr convenienceComponentConfig = boost::make_shared<ConfigItemBuilder>();
-       convenienceComponentConfig->SetType("Component");
-       convenienceComponentConfig->SetName("convenience");
-       convenienceComponentConfig->SetLocal(true);
-       convenienceComponentConfig->Compile()->Commit();
-       convenienceComponentConfig.reset();
 }
 
 /**